I know how to implement basic Adapter design pattern and also knows how C# using delegation to implement Pluggable Adapter design. But I could not find anything implemented in Java. Would you mind pointing out an example code.
Thanks in advance.
I know how to implement basic Adapter design pattern and also knows how C# using delegation to implement Pluggable Adapter design. But I could not find anything implemented in Java. Would you mind pointing out an example code.
Thanks in advance.
Copyright © 2021 Jogjafile Inc.
The pluggable adapter pattern is a technique for creating adapters that doesn't require making a new class for each adaptee interface you need to support.
In Java, this sort of thing is super easy, but there isn't any object involved that would actually correspond to the pluggable adapter object you might use in C#.
Many adapter target interfaces are Functional Interfaces -- interfaces that contain just one method.
When you need to pass an instance of such an interface to a client, you can easily specify an adapter using a lambda function or method reference. For example:
When the target interface has more than one method, we use an anonymous inner class: