I have an interface -- "EventHandler" -- that declares several methods.
public interface EventHandler {
void handleEvent1();
void handleEvent2();
void handleEvent3();
void handleEvent4();
}
I also have a class -- "EventHandlerAdapter" -- that implements EventHandler. However, it doesn't actually "implement" anything. The point is, if another class wants to implement EventHandler, but not all of its methods, it can simply extend EventHandlerAdapter and only override the methods it wants to.
public class EventHandlerAdapter implements EventHandler {
public void handleEvent1() {}
public void handleEvent2() {}
public void handleEvent3() {}
public void handleEvent4() {}
}
I've seen something like this on more than one occasion. The name "EventHandlerAdapter" suggests to me that it is an example of the adapter pattern... but is it really? I thought the point of an adapter was to translate an existing implementation into something else. I don't see how this is the case here.
If it isn't an example of the adapter pattern, what is it? Surely something like this has been identified.