Skip to content

Commit 95c1620

Browse files
committed
Reformat Adapter Pattern - Issue iluwatar#224
1 parent c0c21eb commit 95c1620

File tree

6 files changed

+54
-57
lines changed

6 files changed

+54
-57
lines changed

adapter/src/main/java/com/iluwatar/adapter/App.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,29 @@
22

33
/**
44
*
5-
* An adapter helps two incompatible interfaces to work together. This is the real
6-
* world definition for an adapter. Interfaces may be incompatible but the inner
7-
* functionality should suit the need. The Adapter design pattern allows otherwise
8-
* incompatible classes to work together by converting the interface of one class
9-
* into an interface expected by the clients.
5+
* An adapter helps two incompatible interfaces to work together. This is the real world definition
6+
* for an adapter. Interfaces may be incompatible but the inner functionality should suit the need.
7+
* The Adapter design pattern allows otherwise incompatible classes to work together by converting
8+
* the interface of one class into an interface expected by the clients.
109
* <p>
11-
* There are two variations of the Adapter pattern: The class adapter implements
12-
* the adaptee's interface whereas the object adapter uses composition to
13-
* contain the adaptee in the adapter object. This example uses the object
14-
* adapter approach.
10+
* There are two variations of the Adapter pattern: The class adapter implements the adaptee's
11+
* interface whereas the object adapter uses composition to contain the adaptee in the adapter
12+
* object. This example uses the object adapter approach.
1513
* <p>
16-
* The Adapter ({@link GnomeEngineer}) converts the interface of the target class
17-
* ({@link GoblinGlider}) into a suitable one expected by the client
18-
* ({@link GnomeEngineeringManager}).
14+
* The Adapter ({@link GnomeEngineer}) converts the interface of the target class (
15+
* {@link GoblinGlider}) into a suitable one expected by the client ({@link GnomeEngineeringManager}
16+
* ).
1917
*
2018
*/
2119
public class App {
2220

23-
/**
24-
* Program entry point
25-
* @param args command line args
26-
*/
27-
public static void main(String[] args) {
28-
Engineer manager = new GnomeEngineeringManager();
29-
manager.operateDevice();
30-
}
21+
/**
22+
* Program entry point
23+
*
24+
* @param args command line args
25+
*/
26+
public static void main(String[] args) {
27+
Engineer manager = new GnomeEngineeringManager();
28+
manager.operateDevice();
29+
}
3130
}

adapter/src/main/java/com/iluwatar/adapter/Engineer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
*/
88
public interface Engineer {
99

10-
void operateDevice();
11-
10+
void operateDevice();
1211
}

adapter/src/main/java/com/iluwatar/adapter/GnomeEngineer.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@
22

33
/**
44
*
5-
* Adapter class. Adapts the interface of the device ({@link GoblinGlider}) into
6-
* {@link Engineer} interface expected by the client ({@link GnomeEngineeringManager}).
5+
* Adapter class. Adapts the interface of the device ({@link GoblinGlider}) into {@link Engineer}
6+
* interface expected by the client ({@link GnomeEngineeringManager}).
77
*
88
*/
99
public class GnomeEngineer implements Engineer {
1010

11-
private GoblinGlider glider;
11+
private GoblinGlider glider;
1212

13-
public GnomeEngineer() {
14-
glider = new GoblinGlider();
15-
}
16-
17-
@Override
18-
public void operateDevice() {
19-
glider.attachGlider();
20-
glider.gainSpeed();
21-
glider.takeOff();
22-
}
13+
public GnomeEngineer() {
14+
glider = new GoblinGlider();
15+
}
2316

17+
@Override
18+
public void operateDevice() {
19+
glider.attachGlider();
20+
glider.gainSpeed();
21+
glider.takeOff();
22+
}
2423
}

adapter/src/main/java/com/iluwatar/adapter/GnomeEngineeringManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
*/
88
public class GnomeEngineeringManager implements Engineer {
99

10-
private Engineer engineer;
10+
private Engineer engineer;
1111

12-
public GnomeEngineeringManager() {
13-
engineer = new GnomeEngineer();
14-
}
12+
public GnomeEngineeringManager() {
13+
engineer = new GnomeEngineer();
14+
}
1515

16-
@Override
17-
public void operateDevice() {
18-
engineer.operateDevice();
19-
}
16+
@Override
17+
public void operateDevice() {
18+
engineer.operateDevice();
19+
}
2020
}

adapter/src/main/java/com/iluwatar/adapter/GoblinGlider.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
*/
88
public class GoblinGlider {
99

10-
public void attachGlider() {
11-
System.out.println("Glider attached.");
12-
}
10+
public void attachGlider() {
11+
System.out.println("Glider attached.");
12+
}
1313

14-
public void gainSpeed() {
15-
System.out.println("Gaining speed.");
16-
}
14+
public void gainSpeed() {
15+
System.out.println("Gaining speed.");
16+
}
1717

18-
public void takeOff() {
19-
System.out.println("Lift-off!");
20-
}
18+
public void takeOff() {
19+
System.out.println("Lift-off!");
20+
}
2121
}

adapter/src/test/java/com/iluwatar/adapter/AppTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
*/
1212
public class AppTest {
1313

14-
@Test
15-
public void test() {
16-
String[] args = {};
17-
App.main(args);
18-
}
14+
@Test
15+
public void test() {
16+
String[] args = {};
17+
App.main(args);
18+
}
1919
}

0 commit comments

Comments
 (0)