Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we have *Adapter classes in Spring Java Configuration when they are not Adapters in the general sense

When using Java configuration for Spring, you must seen classes like WebMvcConfigurerAdapter & HandlerInterceptorAdapter which implement a single interface and they are following *Adpater convention which should have been reserved for a real adapter(This specific class doesn't translate calls from one interface to a different interface).

Does any one know whether there is anything wrong with my understanding/they are using wrong convention?

like image 871
Ashok Koyi Avatar asked Sep 29 '22 16:09

Ashok Koyi


1 Answers

Adapter is also commonly used, at least in Java, to name base classes providing do-nothing implementations of all the methods of an interface. This is how Adapter must be understood in this context.

See for example MouseAdapter, MouseInputAdapter, MouseMotionAdapter, etc.

like image 167
JB Nizet Avatar answered Oct 03 '22 03:10

JB Nizet