Reformat Adapter Pattern - Issue #224

This commit is contained in:
Ankur Kaushal 2015-11-01 17:26:57 -05:00
parent c0c21ebd91
commit 95c16200e7
6 changed files with 54 additions and 57 deletions

View File

@ -2,26 +2,25 @@ package com.iluwatar.adapter;
/** /**
* *
* An adapter helps two incompatible interfaces to work together. This is the real * An adapter helps two incompatible interfaces to work together. This is the real world definition
* world definition for an adapter. Interfaces may be incompatible but the inner * for an adapter. Interfaces may be incompatible but the inner functionality should suit the need.
* functionality should suit the need. The Adapter design pattern allows otherwise * The Adapter design pattern allows otherwise incompatible classes to work together by converting
* incompatible classes to work together by converting the interface of one class * the interface of one class into an interface expected by the clients.
* into an interface expected by the clients.
* <p> * <p>
* There are two variations of the Adapter pattern: The class adapter implements * There are two variations of the Adapter pattern: The class adapter implements the adaptee's
* the adaptee's interface whereas the object adapter uses composition to * interface whereas the object adapter uses composition to contain the adaptee in the adapter
* contain the adaptee in the adapter object. This example uses the object * object. This example uses the object adapter approach.
* adapter approach.
* <p> * <p>
* The Adapter ({@link GnomeEngineer}) converts the interface of the target class * The Adapter ({@link GnomeEngineer}) converts the interface of the target class (
* ({@link GoblinGlider}) into a suitable one expected by the client * {@link GoblinGlider}) into a suitable one expected by the client ({@link GnomeEngineeringManager}
* ({@link GnomeEngineeringManager}). * ).
* *
*/ */
public class App { public class App {
/** /**
* Program entry point * Program entry point
*
* @param args command line args * @param args command line args
*/ */
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -8,5 +8,4 @@ package com.iluwatar.adapter;
public interface Engineer { public interface Engineer {
void operateDevice(); void operateDevice();
} }

View File

@ -2,8 +2,8 @@ package com.iluwatar.adapter;
/** /**
* *
* Adapter class. Adapts the interface of the device ({@link GoblinGlider}) into * Adapter class. Adapts the interface of the device ({@link GoblinGlider}) into {@link Engineer}
* {@link Engineer} interface expected by the client ({@link GnomeEngineeringManager}). * interface expected by the client ({@link GnomeEngineeringManager}).
* *
*/ */
public class GnomeEngineer implements Engineer { public class GnomeEngineer implements Engineer {
@ -20,5 +20,4 @@ public class GnomeEngineer implements Engineer {
glider.gainSpeed(); glider.gainSpeed();
glider.takeOff(); glider.takeOff();
} }
} }