Intent - Convert the interface of a class into
another interface clients expect. Adapter lets classes work
together that couldn't otherwise because of incompatible
interfaces.
Problem -
A class that is designed for reuse isn't reusable
because the interface it implments doesn't match the
inteface of the problem domain.
Solution - Class Adapter: Inherit the
interface of the Target and
the Adaptee (if possible, not likely in Java), or
Object Adapter inherit
the interface of the Target, and compose the Adaptee,
calling the method of the Adaptee as appropriate using the
Target interface.
Participants and Collaborators
Target
Client
Adaptee
Adapter
Consequences
A class adapter is usually a little less flexible, since it
is extending a class instead of
implementing a common interface.
An interface layer between Adapter and Adaptees can
be added to make them more flexible.
The adapter can be part of the calling framework,
allowing the adapter to be customized for its use
instead of having the adaptee be concerned about
adapters.
The adapter may need to introduce or transform
parameters as part of its work.