I use the delegation pattern to wrap an object created by a factory in a third-party library. Recently, the library added a protected method to the base class, and my wrapper class no longer works. Does anyone have a good solution without resorting to thought?
This is in a third-party library and in their package,
public class Base {
public void foo();
protected void bar();
}
This is in my own package,
public class MyWrapper extends Base {
private Base delegate;
public MyWrapper(Base delegate) {
this.delegate = delegate;
}
public void foo() {
delegate.foo()
}
protected void bar() {
}
}
EDIT: My original post was not clear. These 2 classes are in different packages.
, . Delegation/Wrapper, . Base, factory Base. . , . .