I have an interface that has ~30 methods and has two different implementations.
I am trying to create another implementation which will have some custom logic and at times it will call one of those existing implementations depending on some conditions.
The issue is that I only want this behavior for a subset of methods, let's say 10 methods.
public interface ITest {
void method1(Param1 param1);
void method2(Param2 param2);
}
public class TestImpl1 implements ITest {
void method1(Param1 param1){
//
}
void method2(Param2 param2){
//
}
}
Let's say, I only want to override method1 in the new implementation and that could call existing implementation in some of the cases.
Delegating the call from a new interface to existing one for method2 seems like a way but I am not sure if that's the best option. Any idea would be appreciated to make it look cleaner.
Thanks!
Impl1
and partImpl2
? Like if you were to create a diamond with multiple inheritance?