What is the design template?

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(){
    //treatment for actionA
    }
    public void actionD(){
    //treatment for actionD
    }
}    
Mylistener l2 = new MylistenerWrapper(){
    public void actionC(){
    //treatment for actionC
    }
}

My question is: which design template? I already called my class wrapper (adapter), is this normal?

+3
source share
1 answer

The adapter is likely (similar to various EventListenerAdapters in Swing).

+1
source

Source: https://habr.com/ru/post/1734431/


All Articles