#1021 Checkstyle fixes for Composite pattern
This commit is contained in:
@ -32,9 +32,9 @@ import org.slf4j.LoggerFactory;
|
||||
* 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
|
||||
* uniformly.
|
||||
* <p>
|
||||
* In this example we have sentences composed of words composed of letters. All of the objects can
|
||||
* be treated through the same interface ({@link LetterComposite}).
|
||||
*
|
||||
* <p>In this example we have sentences composed of words composed of letters. All of the objects
|
||||
* can be treated through the same interface ({@link LetterComposite}).
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
@ -42,7 +42,7 @@ public class App {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* Program entry point.
|
||||
*
|
||||
* @param args command line args
|
||||
*/
|
||||
|
@ -24,20 +24,18 @@
|
||||
package com.iluwatar.composite;
|
||||
|
||||
/**
|
||||
*
|
||||
* Letter
|
||||
*
|
||||
* Letter.
|
||||
*/
|
||||
public class Letter extends LetterComposite {
|
||||
|
||||
private char c;
|
||||
private char character;
|
||||
|
||||
public Letter(char c) {
|
||||
this.c = c;
|
||||
this.character = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void printThisBefore() {
|
||||
System.out.print(c);
|
||||
System.out.print(character);
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Composite interface.
|
||||
*
|
||||
*/
|
||||
public abstract class LetterComposite {
|
||||
|
||||
@ -43,12 +41,14 @@ public abstract class LetterComposite {
|
||||
return children.size();
|
||||
}
|
||||
|
||||
protected void printThisBefore() {}
|
||||
protected void printThisBefore() {
|
||||
}
|
||||
|
||||
protected void printThisAfter() {}
|
||||
protected void printThisAfter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print
|
||||
* Print.
|
||||
*/
|
||||
public void print() {
|
||||
printThisBefore();
|
||||
|
@ -26,9 +26,7 @@ package com.iluwatar.composite;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Messenger
|
||||
*
|
||||
* Messenger.
|
||||
*/
|
||||
public class Messenger {
|
||||
|
||||
|
@ -26,14 +26,12 @@ package com.iluwatar.composite;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Sentence
|
||||
*
|
||||
* Sentence.
|
||||
*/
|
||||
public class Sentence extends LetterComposite {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*/
|
||||
public Sentence(List<Word> words) {
|
||||
for (Word w : words) {
|
||||
|
@ -26,14 +26,12 @@ package com.iluwatar.composite;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Word
|
||||
*
|
||||
* Word.
|
||||
*/
|
||||
public class Word extends LetterComposite {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*/
|
||||
public Word(List<Letter> letters) {
|
||||
for (Letter l : letters) {
|
||||
|
Reference in New Issue
Block a user