A service from external API which I am not allowed to modify returns me
MyClass instance = ServiceUtil.getThing();
I would like to extend this returned class and Add/Override a method but leave intacts the others, say 150 methods.
private class MyWrapperClass extends MyClass(){
public MyWrapperClass(){super();}
@Override public String toString(){ return "Blocked toString"; }
}
Is there any way to force this "casting" from the returned MyClass instance to my newly particular subtype??
NOTE: Please, not suggest the approach of making a constructor, passing the original object and having to copy and implement the 150 methods to call the wrapped object