I would like to add some functions to the object that will be created at runtime. However, the interface for this object is very large (and not under my control). I would like to wrap an object in my class that adds the functionality I want and delegates the standard interface functionality to the original object - is there a way to do this in Java without creating a 1-line copy-paste delegation method for each method in the interface?
What I want to avoid:
class MyFoo implements Foo { Foo wrapped; void myMethod() { ... } void interfaceMethod1() wrapped.interfaceMethod1(); int interfaceMethod2() wrapped.interfaceMethod2();
Which would I prefer:
class MyFoo implements Foo { Foo wrapped; void myMethod() { ... }
source share