Skip to content

Instantly share code, notes, and snippets.

@yinonavraham
Last active February 21, 2017 21:24
Show Gist options
  • Save yinonavraham/10511cdadc5f8f3e845474fb2b526908 to your computer and use it in GitHub Desktop.
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
public interface A {
String foo();
}
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 ***"
}
}
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