@@ -16,15 +16,15 @@ treat individual objects and compositions of objects uniformly.
16
16
17
17
##Explanation
18
18
19
- Real world example
19
+ Real- world example
20
20
21
21
> Every sentence is composed of words which are in turn composed of characters. Each of these
22
- > objectsis printable and they can have something printed before or after them like sentence always
23
- > ends with full stop and word always has space before it.
22
+ > objectsare printable and they can have something printed before or after them like sentence
23
+ > always ends with full stop and word always has space before it.
24
24
25
25
In plain words
26
26
27
- > Composite pattern lets clients treat the individual objects in a uniform manner .
27
+ > Composite pattern lets clientsuniformly treat the individual objects.
28
28
29
29
Wikipedia says
30
30
@@ -154,10 +154,22 @@ public class Messenger {
154
154
And then it can be used as:
155
155
156
156
``` java
157
- var orcMessage= new Messenger (). messageFromOrcs();
158
- orcMessage. print();// Where there is a whip there is a way.
159
- var elfMessage= new Messenger (). messageFromElves();
160
- elfMessage. print();// Much wind pours from your mouth.
157
+ var messenger= new Messenger ();
158
+
159
+ LOGGER . info(" Message from the orcs:" );
160
+ messenger. messageFromOrcs(). print();
161
+
162
+ LOGGER . info(" Message from the elves:" );
163
+ messenger. messageFromElves(). print();
164
+ ```
165
+
166
+ The console output:
167
+
168
+ ```
169
+ Message from the orcs:
170
+ Where there is a whip there is a way.
171
+ Message from the elves:
172
+ Much wind pours from your mouth.
161
173
```
162
174
163
175
##Class diagram
@@ -172,7 +184,7 @@ Use the Composite pattern when
172
184
* You want clients to be able to ignore the difference between compositions of objects and
173
185
individual objects. Clients will treat all objects in the composite structure uniformly.
174
186
175
- ##Real world examples
187
+ ##Known uses
176
188
177
189
* [ java.awt.Container] ( http://docs.oracle.com/javase/8/docs/api/java/awt/Container.html ) and[ java.awt.Component] ( http://docs.oracle.com/javase/8/docs/api/java/awt/Component.html )
178
190
* [ Apache Wicket] ( https://github.com/apache/wicket ) component tree, see[ Component] ( https://github.com/apache/wicket/blob/91e154702ab1ff3481ef6cbb04c6044814b7e130/wicket-core/src/main/java/org/apache/wicket/Component.java ) and[ MarkupContainer] ( https://github.com/apache/wicket/blob/b60ec64d0b50a611a9549809c9ab216f0ffa3ae3/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java )