title: Automated delegation in Java
body: <p>I would like to add some functionality to an object that will be generated at runtime.  However, the interface for this object is very large (and not under my control).  I would like to wrap the object in my own class which adds the functionality I want and delegates the standard interface functionality to the original object - is there any way to do this in Java without creating a 1-line copy-paste delegator method for every method in the interface?</p>
  
  <p>What I want to avoid:</p>
  
  <pre><code>class MyFoo implements Foo {
    Foo wrapped;
  
    void myMethod() { ... }
  
    void interfaceMethod1() wrapped.interfaceMethod1();
    int interfaceMethod2() wrapped.interfaceMethod2();
    // etc etc ...
  }
  </code></pre>
  
  <p>What I would prefer:</p>
  
  <pre><code>class MyFoo implements Foo {
    Foo wrapped;
  
    void myMethod() { ... }
  
    // automatically delegate undefined methods to wrapped object
  }
  </code></pre>