Adapter pattern comes under Structural design pattern.
Converts the interface of one class into another interface that client expects.
It is also know as wrapper pattern.
Behaviour & Advantages
Lets classes work together that couldn't otherwise because of incompatible interfaces.
Wraps the existing functionality with new functionality.
Wrapped implementation is completely hidden from the client.
New abstract interface that client is expecting.
An implementation of Target by wrapping the functionality of Adaptee.
Adapter may wrap the Adaptee functionality either by inheritance (extend Adaptee)
or Containership (Keep a reference of Adaptee in Adapter and deligate calls as needed).
It maps the client interface to the adaptee interface.
Existing functionality or legacy code that needs adapting.
One who uses new Target interface.
This example shows a simple stack implementation from legacy Vector class.
Here interface IStack acts as Target interface and
StackAdapter acts as Adapter which wraps the functionality of Vector (Adaptee).