Java Inheritance and Wrapping -
i have generated object want to:
- preserve existing functionality of without injecting constructor , rewriting every method call
injectedobject.samemethod(). - 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
Post a Comment