File tree Expand file tree Collapse file tree 6 files changed +18
-26
lines changed
composite/src/main/java/com/iluwatar/composite Expand file tree Collapse file tree 6 files changed +18
-26
lines changed Original file line number Diff line number Diff line change 32
32
* of a composite is to "compose" objects into tree structures to represent part-whole hierarchies.
33
33
* Implementing the Composite pattern lets clients treat individual objects and compositions
34
34
* uniformly.
35
- * <p>
36
- * In this example we have sentences composed of words composed of letters. All of the objects can
37
- * be treated through the same interface ({@link LetterComposite}).
35
+ *
36
+ * <p> In this example we have sentences composed of words composed of letters. All of the objects
37
+ * can be treated through the same interface ({@link LetterComposite}).
38
38
*
39
39
*/
40
40
public class App {
41
41
42
42
private static final Logger LOGGER = LoggerFactory .getLogger (App .class );
43
43
44
44
/**
45
- * Program entry point
45
+ * Program entry point.
46
46
*
47
47
* @param args command line args
48
48
*/
Original file line number Diff line number Diff line change 24
24
package com .iluwatar .composite ;
25
25
26
26
/**
27
- *
28
- * Letter
29
- *
27
+ * Letter.
30
28
*/
31
29
public class Letter extends LetterComposite {
32
30
33
- private char c ;
31
+ private char character ;
34
32
35
33
public Letter (char c ) {
36
- this .c = c ;
34
+ this .character = c ;
37
35
}
38
36
39
37
@ Override
40
38
protected void printThisBefore () {
41
- System .out .print (c );
39
+ System .out .print (character );
42
40
}
43
41
}
Original file line number Diff line number Diff line change 27
27
import java .util .List ;
28
28
29
29
/**
30
- *
31
30
* Composite interface.
32
- *
33
31
*/
34
32
public abstract class LetterComposite {
35
33
@@ -43,12 +41,14 @@ public int count() {
43
41
return children .size ();
44
42
}
45
43
46
- protected void printThisBefore () {}
44
+ protected void printThisBefore () {
45
+ }
47
46
48
- protected void printThisAfter () {}
47
+ protected void printThisAfter () {
48
+ }
49
49
50
50
/**
51
- * Print
51
+ * Print.
52
52
*/
53
53
public void print () {
54
54
printThisBefore ();
Original file line number Diff line number Diff line change 26
26
import java .util .List ;
27
27
28
28
/**
29
- *
30
- * Messenger
31
- *
29
+ * Messenger.
32
30
*/
33
31
public class Messenger {
34
32
Original file line number Diff line number Diff line change 26
26
import java .util .List ;
27
27
28
28
/**
29
- *
30
- * Sentence
31
- *
29
+ * Sentence.
32
30
*/
33
31
public class Sentence extends LetterComposite {
34
32
35
33
/**
36
- * Constructor
34
+ * Constructor.
37
35
*/
38
36
public Sentence (List <Word > words ) {
39
37
for (Word w : words ) {
Original file line number Diff line number Diff line change 26
26
import java .util .List ;
27
27
28
28
/**
29
- *
30
- * Word
31
- *
29
+ * Word.
32
30
*/
33
31
public class Word extends LetterComposite {
34
32
35
33
/**
36
- * Constructor
34
+ * Constructor.
37
35
*/
38
36
public Word (List <Letter > letters ) {
39
37
for (Letter l : letters ) {
You can’t perform that action at this time.
0 commit comments