Resolves checkstyle errors for collection-pipeline, command, commander (#1061)
* Reduces checkstyle errors in collection-pipeline * Reduces checkstyle errors in command * Reduces checkstyle errors in commander
This commit is contained in:
committed by
Ilkka Seppälä
parent
31f27a720b
commit
2f49648047
@ -24,31 +24,28 @@
|
||||
package com.iluwatar.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* The Command pattern is a behavioral design pattern in which an object is used to encapsulate all
|
||||
* information needed to perform an action or trigger an event at a later time. This information
|
||||
* includes the method name, the object that owns the method and values for the method parameters.
|
||||
* <p>
|
||||
* Four terms always associated with the command pattern are command, receiver, invoker and client.
|
||||
* A command object (spell) knows about the receiver (target) and invokes a method of the receiver.
|
||||
* Values for parameters of the receiver method are stored in the command. The receiver then does
|
||||
* the work. An invoker object (wizard) knows how to execute a command, and optionally does
|
||||
* bookkeeping about the command execution. The invoker does not know anything about a concrete
|
||||
*
|
||||
* <p>Four terms always associated with the command pattern are command, receiver, invoker and
|
||||
* client. A command object (spell) knows about the receiver (target) and invokes a method of the
|
||||
* receiver. Values for parameters of the receiver method are stored in the command. The receiver
|
||||
* then does the work. An invoker object (wizard) knows how to execute a command, and optionally
|
||||
* does bookkeeping about the command execution. The invoker does not know anything about a concrete
|
||||
* command, it knows only about command interface. Both an invoker object and several command
|
||||
* objects are held by a client object (app). The client decides which commands to execute at which
|
||||
* points. To execute a command, it passes the command object to the invoker object.
|
||||
* <p>
|
||||
* In other words, in this example the wizard casts spells on the goblin. The wizard keeps track of
|
||||
* the previous spells cast, so it is easy to undo them. In addition, the wizard keeps track of the
|
||||
* spells undone, so they can be redone.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <p>In other words, in this example the wizard casts spells on the goblin. The wizard keeps track
|
||||
* of the previous spells cast, so it is easy to undo them. In addition, the wizard keeps track of
|
||||
* the spells undone, so they can be redone.
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
*
|
||||
* Program entry point.
|
||||
*
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* Interface for Commands.
|
||||
*
|
||||
*/
|
||||
public abstract class Command {
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* Goblin is the target of the spells
|
||||
*
|
||||
* Goblin is the target of the spells.
|
||||
*/
|
||||
public class Goblin extends Target {
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* InvisibilitySpell is a concrete command
|
||||
*
|
||||
* InvisibilitySpell is a concrete command.
|
||||
*/
|
||||
public class InvisibilitySpell extends Command {
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* ShrinkSpell is a concrete command
|
||||
*
|
||||
* ShrinkSpell is a concrete command.
|
||||
*/
|
||||
public class ShrinkSpell extends Command {
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enumeration for target size.
|
||||
*
|
||||
*/
|
||||
public enum Size {
|
||||
|
||||
|
@ -27,9 +27,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* Base class for spell targets.
|
||||
*
|
||||
*/
|
||||
public abstract class Target {
|
||||
|
||||
@ -59,7 +57,7 @@ public abstract class Target {
|
||||
public abstract String toString();
|
||||
|
||||
/**
|
||||
* Print status
|
||||
* Print status.
|
||||
*/
|
||||
public void printStatus() {
|
||||
LOGGER.info("{}, [size={}] [visibility={}]", this, getSize(), getVisibility());
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enumeration for target visibility.
|
||||
*
|
||||
*/
|
||||
public enum Visibility {
|
||||
|
||||
|
@ -23,16 +23,13 @@
|
||||
|
||||
package com.iluwatar.command;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
*
|
||||
* Wizard is the invoker of the commands
|
||||
*
|
||||
* Wizard is the invoker of the commands.
|
||||
*/
|
||||
public class Wizard {
|
||||
|
||||
@ -46,7 +43,7 @@ public class Wizard {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast spell
|
||||
* Cast spell.
|
||||
*/
|
||||
public void castSpell(Command command, Target target) {
|
||||
LOGGER.info("{} casts {} at {}", this, command, target);
|
||||
@ -55,7 +52,7 @@ public class Wizard {
|
||||
}
|
||||
|
||||
/**
|
||||
* Undo last spell
|
||||
* Undo last spell.
|
||||
*/
|
||||
public void undoLastSpell() {
|
||||
if (!undoStack.isEmpty()) {
|
||||
@ -67,7 +64,7 @@ public class Wizard {
|
||||
}
|
||||
|
||||
/**
|
||||
* Redo last spell
|
||||
* Redo last spell.
|
||||
*/
|
||||
public void redoLastSpell() {
|
||||
if (!redoStack.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user