Merge pull request #281 from ankurkaushal/master

Reformat according to google style guide
This commit is contained in:
Ilkka Seppälä
2015-11-02 21:39:17 +02:00
438 changed files with 8257 additions and 8382 deletions

View File

@ -2,30 +2,29 @@ package com.iluwatar.adapter;
/**
*
* An adapter helps two incompatible interfaces to work together. This is the real
* world definition for an adapter. Interfaces may be incompatible but the inner
* functionality should suit the need. The Adapter design pattern allows otherwise
* incompatible classes to work together by converting the interface of one class
* into an interface expected by the clients.
* An adapter helps two incompatible interfaces to work together. This is the real world definition
* for an adapter. Interfaces may be incompatible but the inner functionality should suit the need.
* The Adapter design pattern allows otherwise incompatible classes to work together by converting
* the interface of one class into an interface expected by the clients.
* <p>
* 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.
* 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}).
* 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();
}
/**
* Program entry point
*
* @param args command line args
*/
public static void main(String[] args) {
Engineer manager = new GnomeEngineeringManager();
manager.operateDevice();
}
}

View File

@ -7,6 +7,5 @@ package com.iluwatar.adapter;
*/
public interface Engineer {
void operateDevice();
void operateDevice();
}

View File

@ -2,23 +2,22 @@ package com.iluwatar.adapter;
/**
*
* Adapter class. Adapts the interface of the device ({@link GoblinGlider}) into
* {@link Engineer} interface expected by the client ({@link GnomeEngineeringManager}).
* 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;
private GoblinGlider glider;
public GnomeEngineer() {
glider = new GoblinGlider();
}
@Override
public void operateDevice() {
glider.attachGlider();
glider.gainSpeed();
glider.takeOff();
}
public GnomeEngineer() {
glider = new GoblinGlider();
}
@Override
public void operateDevice() {
glider.attachGlider();
glider.gainSpeed();
glider.takeOff();
}
}

View File

@ -7,14 +7,14 @@ package com.iluwatar.adapter;
*/
public class GnomeEngineeringManager implements Engineer {
private Engineer engineer;
private Engineer engineer;
public GnomeEngineeringManager() {
engineer = new GnomeEngineer();
}
public GnomeEngineeringManager() {
engineer = new GnomeEngineer();
}
@Override
public void operateDevice() {
engineer.operateDevice();
}
@Override
public void operateDevice() {
engineer.operateDevice();
}
}

View File

@ -7,15 +7,15 @@ package com.iluwatar.adapter;
*/
public class GoblinGlider {
public void attachGlider() {
System.out.println("Glider attached.");
}
public void attachGlider() {
System.out.println("Glider attached.");
}
public void gainSpeed() {
System.out.println("Gaining speed.");
}
public void gainSpeed() {
System.out.println("Gaining speed.");
}
public void takeOff() {
System.out.println("Lift-off!");
}
public void takeOff() {
System.out.println("Lift-off!");
}
}

View File

@ -11,9 +11,9 @@ import com.iluwatar.adapter.App;
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
}
@Test
public void test() {
String[] args = {};
App.main(args);
}
}