Intent

Convert the existing interfaces to a new interface to achieve compatibility and reusability of the unrelated classes in one application. Also known as Wrapper pattern.

Where to use & benefits

Structure


Participants

Target  (ShapeDecorator)
defines the domain-specific interface that Client uses.

Adaptee  (ColorDecorator)
defines an existing interface that needs adapting.

Adapter  (IShape)
adapts the interface of Adaptee to the Target interface.

Client  (MainApplet)
collaborates with objects conforming to the Target interface.

Example

In the demonstration application, to draw the shape (drawShape()), ColorDecorator class uses IShape instance implementation of drawShape() method.

Class Diagram


Source Code Links