Created
June 26, 2016 14:31
-
-
Save Zikoel/9a79cc489af87f386434756f9b5be922 to your computer and use it in GitHub Desktop.
Java generics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class A { | |
public A() { | |
MainApp.decorateMyClass(this); | |
} | |
} | |
public class B { | |
public B() { | |
MainApp.decorateMyClass(this); | |
} | |
} | |
public interface Decorator() { | |
void decorate(A a); | |
void decorate(B b); | |
} | |
public class MainApp { | |
private Decorator decorator; | |
private static MainApp mainApp; | |
public MainApp() { | |
mainApp = this; | |
decorato = getConcreteFromSomewhere(); | |
} | |
public static <T> void decorateMyClass(Class<T> clazz) { | |
decorator.decorate(clazz); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment