I have an interface declaring 4 methods ... I added an abstract class that implements this interface to give developers the opportunity to choose how many methods they want to implement (especially useful in the case of a listener) ...
public interface Mylistener {
void actionA();
void actionB();
void actionC();
void actionD();
}
public abstract class MylistenerWrapper implements Mylistener {
public void actionA(){}
public void actionB(){}
public void actionC(){}
public void actionD(){}
}
and now developers are not required to implement all interface methods:
Mylistener l1 = new MylistenerWrapper(){
public void actionA(){
}
public void actionD(){
}
}
Mylistener l2 = new MylistenerWrapper(){
public void actionC(){
}
}
My question is: which design template? I already called my class wrapper (adapter), is this normal?
source
share