I have the following hierarchy in java:
interface ObserverA {}
interface A {
void method1();
addObserver(Observer o);
}
And I want to expand it as follows:
interface ObserverB extends ObserverA{}
interface B extends A {
void method2();
addObserver(ObserverB o);
}
so that the method addObserver() Boverrides the same method in A. Since it does not work, implementations Bwill need to implement both versions addObserver(), I will not have only one.
Is it possible to do this in a smart way that does not require parameterization Aas:
interface A<O extends Observer> {
addObserver(O o);
}
Welcome Hackish Solutions!
source
share