Package org.mwolff.command
Class DefaultCommandContainer<T>
- java.lang.Object
-
- org.mwolff.command.DefaultCommandContainer<T>
-
- All Implemented Interfaces:
ChainCommand<T>
,Command<T>
,CommandContainer<T>
,ProcessCommand<T>
public class DefaultCommandContainer<T> extends Object implements CommandContainer<T>
CommandContainer that holds Command-objects. Should have the same behavior as a command (Composite Pattern).- Author:
- Manfred Wolff
-
-
Field Summary
-
Fields inherited from interface org.mwolff.command.process.ProcessCommand
END
-
-
Constructor Summary
Constructors Constructor Description DefaultCommandContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandContainer<T>
addCommand(int priority, Command<T> command)
Adds aCommand
to the list via priority.CommandContainer<T>
addCommand(Command<T> command)
Adds aCommand
to the list.Optional<String>
executeAsProcess(String startCommand, T context)
Execute a command as a process.Optional<String>
executeAsProcess(T context)
Execute a command as a process.CommandTransition
executeCommand(T parameterObject)
Executes the command.CommandTransition
executeCommandAsChain(T parameterObject)
Optional<ProcessCommand<T>>
getCommandByProcessID(String proceddID)
Gets the command with the certain processID.String
getProcessID()
Gets the process ID of the command.void
setProcessID(String processID)
Sets the process ID of the command-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.mwolff.command.process.ProcessCommand
addTransition, findNext, getTransitionList
-
-
-
-
Method Detail
-
addCommand
public CommandContainer<T> addCommand(Command<T> command)
Description copied from interface:CommandContainer
Adds aCommand
to the list. Because aCommandContainer
is aCommand
you can addCommandContainer
objects as well.- Specified by:
addCommand
in interfaceCommandContainer<T>
- Parameters:
command
- The command to add.- Returns:
- this
- See Also:
CommandContainer.addCommand(org.mwolff.command.Command)
-
addCommand
public CommandContainer<T> addCommand(int priority, Command<T> command)
Description copied from interface:CommandContainer
Adds aCommand
to the list via priority. Because aCommandContainer
is aCommand
you can addCommandContainer
objects as well.- Specified by:
addCommand
in interfaceCommandContainer<T>
- Parameters:
priority
- A priority. If two commands has the same priority the first wins.command
- The command to add.- Returns:
- this
- See Also:
CommandContainer.addCommand(int, org.mwolff.command.Command)
-
executeCommandAsChain
public CommandTransition executeCommandAsChain(T parameterObject)
- Specified by:
executeCommandAsChain
in interfaceChainCommand<T>
- Parameters:
parameterObject
- The parameter object to pass.- Returns:
- SUCCESS is the next chain should overtake, ABORT otherwise.
-
executeAsProcess
public Optional<String> executeAsProcess(String startCommand, T context)
Description copied from interface:ProcessCommand
Execute a command as a process. The result is the decision which process step should be executed next.- Specified by:
executeAsProcess
in interfaceProcessCommand<T>
- Parameters:
startCommand
- The command the process should start with.context
- The context to work with.- Returns:
- The next process step to execute. Null stops the process.
- See Also:
ProcessCommand.executeAsProcess(java.lang.String, java.lang.Object)
-
getCommandByProcessID
public Optional<ProcessCommand<T>> getCommandByProcessID(String proceddID)
Description copied from interface:CommandContainer
Gets the command with the certain processID.- Specified by:
getCommandByProcessID
in interfaceCommandContainer<T>
- Parameters:
proceddID
- The id to find the command.- Returns:
- The command with the certain processID
-
getProcessID
public String getProcessID()
Description copied from interface:ProcessCommand
Gets the process ID of the command.- Specified by:
getProcessID
in interfaceProcessCommand<T>
- Returns:
- The process ID
-
setProcessID
public void setProcessID(String processID)
Description copied from interface:ProcessCommand
Sets the process ID of the command- Specified by:
setProcessID
in interfaceProcessCommand<T>
- Parameters:
processID
- Sets the process id of this process command.
-
executeAsProcess
public Optional<String> executeAsProcess(T context)
Description copied from interface:ProcessCommand
Execute a command as a process. The result is the decision which process step should be executed next.- Specified by:
executeAsProcess
in interfaceProcessCommand<T>
- Parameters:
context
- The context to work with.- Returns:
- The next process step to execute. Null stops the process.
-
executeCommand
public CommandTransition executeCommand(T parameterObject)
Description copied from interface:Command
Executes the command. The command can have the result SUCCESS if everything is fine or FAILURE if an error occurred.- Specified by:
executeCommand
in interfaceCommand<T>
- Parameters:
parameterObject
- The parameter object to pass.- Returns:
- FAILURE if something went wrong, SUCCESS otherwise.
-
-