Adapter PatternAn 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 PatternLet'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:Step 1Create a CreditCard interface (Target interface). Step 2Create a BankDetails class (Adaptee class). File: BankDetails.java Step 3Create a BankCustomer class (Adapter class). File: BankCustomer.java Step 4Create a AdapterPatternDemo class (client class). File: AdapterPatternDemo.java OutputNext TopicBridge Pattern |