An Adapter Pattern says that just "converts the interface of a class into another interface that a client wants".
In other words, to provide the interface according to client requirement while using the services of a class with a different interface.
The Adapter Pattern is also known as Wrapper.
Advantage of Adapter Pattern
Usage of Adapter pattern:
It is used:
Example of Adapter Pattern
Let's understand the example of adapter design pattern by the above UML diagram.
UML for Adapter Pattern:
There are the following specifications for the adapter pattern:
Implementation of above UML:
Create a CreditCard interface (Target interface).
Create a BankDetails class (Adaptee class).
Create a BankCustomer class (Adapter class).
Create a AdapterPatternDemo class (client class).