Last active
February 21, 2017 21:24
-
-
Save yinonavraham/10511cdadc5f8f3e845474fb2b526908 to your computer and use it in GitHub Desktop.
Part of the following post in orange-coding.blogspot.com: Enhancing (extending) a class using dynamic proxy classes in Java
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 interface A { | |
String foo(); | |
} |
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 ADecorator implements A { | |
private final A delegate; | |
public ADecorator(A a) { | |
this.delegate = a; | |
} | |
public String foo() { | |
return "*** " + this.delegate.foo() + " ***"; //will return "*** foo ***" | |
} | |
} |
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 AImpl implements A { | |
public String foo() { | |
return "foo"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment