#107 JavaDoc improvements for the Adapter example
This commit is contained in:
parent
fd85a2f848
commit
ef6a34ef74
@ -1,21 +1,25 @@
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* There are two variations of the Adapter pattern: The class adapter implements
|
||||
* the adaptee's interface whereas the object adapter uses composition to
|
||||
* contain the adaptee in the adapter object. This example uses the object
|
||||
* adapter approach.
|
||||
*
|
||||
* The Adapter (GnomeEngineer) converts the interface of the target class
|
||||
* (GoblinGlider) into a suitable one expected by the client
|
||||
* (GnomeEngineeringManager).
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Engineer manager = new GnomeEngineeringManager();
|
||||
manager.operateDevice();
|
||||
}
|
||||
}
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* There are two variations of the Adapter pattern: The class adapter implements
|
||||
* the adaptee's interface whereas the object adapter uses composition to
|
||||
* contain the adaptee in the adapter object. This example uses the object
|
||||
* adapter approach.
|
||||
* <p>
|
||||
* The Adapter ({@link GnomeEngineer}) converts the interface of the target class
|
||||
* ({@link GoblinGlider}) into a suitable one expected by the client
|
||||
* ({@link GnomeEngineeringManager}).
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Engineer manager = new GnomeEngineeringManager();
|
||||
manager.operateDevice();
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* Adapter class. Adapts the interface of the device (GoblinGlider) into
|
||||
* Engineer interface expected by the client (GnomeEngineeringManager).
|
||||
*
|
||||
*/
|
||||
public class GnomeEngineer implements Engineer {
|
||||
|
||||
private GoblinGlider glider;
|
||||
|
||||
public GnomeEngineer() {
|
||||
glider = new GoblinGlider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operateDevice() {
|
||||
glider.attachGlider();
|
||||
glider.gainSpeed();
|
||||
glider.takeOff();
|
||||
}
|
||||
|
||||
}
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* Adapter class. Adapts the interface of the device ({@link GoblinGlider}) into
|
||||
* {@link Engineer} interface expected by the client ({@link GnomeEngineeringManager}).
|
||||
*
|
||||
*/
|
||||
public class GnomeEngineer implements Engineer {
|
||||
|
||||
private GoblinGlider glider;
|
||||
|
||||
public GnomeEngineer() {
|
||||
glider = new GoblinGlider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operateDevice() {
|
||||
glider.attachGlider();
|
||||
glider.gainSpeed();
|
||||
glider.takeOff();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* GnomeEngineering manager uses Engineer to operate devices.
|
||||
*
|
||||
*/
|
||||
public class GnomeEngineeringManager implements Engineer {
|
||||
|
||||
private Engineer engineer;
|
||||
|
||||
public GnomeEngineeringManager() {
|
||||
engineer = new GnomeEngineer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operateDevice() {
|
||||
engineer.operateDevice();
|
||||
}
|
||||
}
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* GnomeEngineering manager uses {@link Engineer} to operate devices.
|
||||
*
|
||||
*/
|
||||
public class GnomeEngineeringManager implements Engineer {
|
||||
|
||||
private Engineer engineer;
|
||||
|
||||
public GnomeEngineeringManager() {
|
||||
engineer = new GnomeEngineer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operateDevice() {
|
||||
engineer.operateDevice();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user