|
24 | 24 | package com.iluwatar.adapter; |
25 | 25 |
|
26 | 26 | /** |
27 | | - * An adapter helps two incompatible interfaces to work together. This is the real world definition |
28 | | - * for an adapter. Interfaces may be incompatible but the inner functionality should suit the need. |
29 | | - * The Adapter design pattern allows otherwise incompatible classes to work together by converting |
30 | | - * the interface of one class into an interface expected by the clients. |
| 27 | + * An adapter helps two incompatible interfaces to work together. This is the |
| 28 | + * real world definition for an adapter. Interfaces may be incompatible but |
| 29 | + * the inner functionality should suit the need. The Adapter design pattern |
| 30 | + * allows otherwise incompatible classes to work together by converting the |
| 31 | + * interface of one class into an interface expected by the clients. |
31 | 32 | * |
32 | 33 | * <p> |
33 | | - * There are two variations of the Adapter pattern: The class adapter implements the adaptee's |
34 | | - * interface whereas the object adapter uses composition to contain the adaptee in the adapter |
35 | | - * object. This example uses the object adapter approach. |
| 34 | + * There are two variations of the Adapter pattern: The class adapter |
| 35 | + * implements the adaptee's interface whereas the object adapter uses |
| 36 | + * composition to contain the adaptee in the adapter object. This example uses |
| 37 | + * the object adapter approach. |
36 | 38 | * |
37 | 39 | * <p> |
38 | | - * The Adapter ({@link FishingBoatAdapter}) converts the interface of the adaptee class ( |
39 | | - * {@link FishingBoat}) into a suitable one expected by the client ( {@link RowingBoat} ). |
| 40 | + * The Adapter ({@link FishingBoatAdapter}) converts the interface of the |
| 41 | + * adaptee class ({@link FishingBoat}) into a suitable one expected by the |
| 42 | + * client ({@link RowingBoat}). |
40 | 43 | * |
41 | 44 | * <p> |
42 | 45 | * The story of this implementation is this. <br> |
43 | | - * Pirates are coming! we need a {@link RowingBoat} to flee! We have a {@link FishingBoat} and our |
44 | | - * captain. We have no time to make up a new ship! we need to reuse this {@link FishingBoat}. The |
45 | | - * captain needs a rowing boat which he can operate. The spec is in {@link RowingBoat}. We will |
46 | | - * use the Adapter pattern to reuse {@link FishingBoat}. |
| 46 | + * Pirates are coming! we need a {@link RowingBoat} to flee! We have a |
| 47 | + * {@link FishingBoat} and our captain. We have no time to make up a new ship! |
| 48 | + * we need to reuse this {@link FishingBoat}. The captain needs a rowing boat |
| 49 | + * which he can operate. The spec is in {@link RowingBoat}. We will use the |
| 50 | + * Adapter pattern to reuse {@link FishingBoat}. |
47 | 51 | * |
48 | 52 | */ |
49 | | -public class App { |
| 53 | +public final class App { |
| 54 | + |
| 55 | + private App() { } |
50 | 56 |
|
51 | 57 | /** |
52 | 58 | * Program entry point. |
53 | 59 | * |
54 | 60 | * @param args command line args |
55 | 61 | */ |
56 | | - public static void main(String[] args) { |
57 | | - // The captain can only operate rowing boats but with adapter he is able to use fishing boats as well |
| 62 | + public static void main(final String[] args) { |
| 63 | + // The captain can only operate rowing boats but with adapter he is able to |
| 64 | + // use fishing boats as well |
58 | 65 | var captain = new Captain(new FishingBoatAdapter()); |
59 | 66 | captain.row(); |
60 | 67 | } |
|
0 commit comments