#1021 Checkstyle fixes for Composite pattern

This commit is contained in:
Ilkka Seppälä
2019-11-05 17:22:53 +02:00
parent 0b17abdf11
commit 7dc47da131
6 changed files with 18 additions and 26 deletions

View File

@ -32,9 +32,9 @@ import org.slf4j.LoggerFactory;
* of a composite is to "compose" objects into tree structures to represent part-whole hierarchies. * of a composite is to "compose" objects into tree structures to represent part-whole hierarchies.
* Implementing the Composite pattern lets clients treat individual objects and compositions * Implementing the Composite pattern lets clients treat individual objects and compositions
* uniformly. * uniformly.
* <p> *
* In this example we have sentences composed of words composed of letters. All of the objects can * <p>In this example we have sentences composed of words composed of letters. All of the objects
* be treated through the same interface ({@link LetterComposite}). * can be treated through the same interface ({@link LetterComposite}).
* *
*/ */
public class App { public class App {
@ -42,7 +42,7 @@ public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class); private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/** /**
* Program entry point * Program entry point.
* *
* @param args command line args * @param args command line args
*/ */

View File

@ -24,20 +24,18 @@
package com.iluwatar.composite; package com.iluwatar.composite;
/** /**
* * Letter.
* Letter
*
*/ */
public class Letter extends LetterComposite { public class Letter extends LetterComposite {
private char c; private char character;
public Letter(char c) { public Letter(char c) {
this.c = c; this.character = c;
} }
@Override @Override
protected void printThisBefore() { protected void printThisBefore() {
System.out.print(c); System.out.print(character);
} }
} }

View File

@ -27,9 +27,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
*
* Composite interface. * Composite interface.
*
*/ */
public abstract class LetterComposite { public abstract class LetterComposite {
@ -43,12 +41,14 @@ public abstract class LetterComposite {
return children.size(); return children.size();
} }
protected void printThisBefore() {} protected void printThisBefore() {
}
protected void printThisAfter() {} protected void printThisAfter() {
}
/** /**
* Print * Print.
*/ */
public void print() { public void print() {
printThisBefore(); printThisBefore();

View File

@ -26,9 +26,7 @@ package com.iluwatar.composite;
import java.util.List; import java.util.List;
/** /**
* * Messenger.
* Messenger
*
*/ */
public class Messenger { public class Messenger {

View File

@ -26,14 +26,12 @@ package com.iluwatar.composite;
import java.util.List; import java.util.List;
/** /**
* * Sentence.
* Sentence
*
*/ */
public class Sentence extends LetterComposite { public class Sentence extends LetterComposite {
/** /**
* Constructor * Constructor.
*/ */
public Sentence(List<Word> words) { public Sentence(List<Word> words) {
for (Word w : words) { for (Word w : words) {

View File

@ -26,14 +26,12 @@ package com.iluwatar.composite;
import java.util.List; import java.util.List;
/** /**
* * Word.
* Word
*
*/ */
public class Word extends LetterComposite { public class Word extends LetterComposite {
/** /**
* Constructor * Constructor.
*/ */
public Word(List<Letter> letters) { public Word(List<Letter> letters) {
for (Letter l : letters) { for (Letter l : letters) {