Java Inheritance and Wrapping -


i have generated object want to:

  1. preserve existing functionality of without injecting constructor , rewriting every method call injectedobject.samemethod().
  2. add additional functionality generated object without modifying generated object.

add additional functionality to.

for example:

public class generatedobject {     public string getthis() { ... }     public string getthat() { ... } }  public interface objectwrapper {     string dothiswiththat(); }  public class objectwrapperimpl extends generatedobject implements objectwrapper {     string dothiswiththat() { ... } } 

however, downcasting not allowed, proper implementation without rewriting bunch of redundant code wrap object?

i think decorator pattern may you: "the decorator pattern can used extend (decorate) functionality of object @ run-time, independently of other instances of same class"


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -