Package api.advanced
Class Collection
- java.lang.Object
-
- api.advanced.Collection
-
- All Implemented Interfaces:
ExecutableCommands
- Direct Known Subclasses:
Sequence
public class Collection extends java.lang.Object implements ExecutableCommands
A tool to combine multipleExecutableCommands
into one object, which runs all contained commands in parallel.
-
-
Constructor Summary
Constructors Constructor Description Collection()
Create a new, empty Collection.Collection(ExecutableCommands[] commands)
Create a collection and initialize it with theExecutableCommands
contained in the array
-
Method Summary
Modifier and Type Method Description void
add(ExecutableCommands command)
Add anExecutableCommand
to the commands contained in thisCollection
boolean
equals(java.lang.Object obj)
void
exec()
Call theexec()
methods of all contained commandsvoid
exec(int time)
Call theexec(int)
methods of all contained commands with the provided time as the argumentvoid
execBlocking()
LikeExecutableCommands.exec()
but blocks the Thread until the Command has been executedvoid
execBlocking(int time)
LikeExecutableCommands.exec(int)
but blocks the Thread until the Command has been executedExecutableCommands
getCommand(int index)
java.util.ArrayList<ExecutableCommands>
getCommands()
int
getTime()
Get the default execution time of this Commandjava.lang.String
getTree()
Returns aString
containing a tree showing the hierarchy ofExecutableCommands
in this Collectionvoid
printTree()
Print the result ofgetTree
void
remove(ExecutableCommands command)
Remove the first occurrence of a command equal to the one provided as an argument from the collection
This method is an alias ofcommands.remove(command)
-
-
-
Constructor Detail
-
Collection
public Collection()
Create a new, empty Collection.
-
Collection
public Collection(ExecutableCommands[] commands)
Create a collection and initialize it with theExecutableCommands
contained in the array- Parameters:
commands
- An array of ExecutableCommands
-
-
Method Detail
-
exec
public void exec()
Call theexec()
methods of all contained commands- Specified by:
exec
in interfaceExecutableCommands
- See Also:
exec(int)
-
exec
public void exec(int time)
Call theexec(int)
methods of all contained commands with the provided time as the argument- Specified by:
exec
in interfaceExecutableCommands
- Parameters:
time
- Argument forExecutableCommands.exec(int)
- See Also:
exec()
-
add
public void add(ExecutableCommands command)
Add anExecutableCommand
to the commands contained in thisCollection
- Parameters:
command
- The ExecutableCommand to be added
-
remove
public void remove(ExecutableCommands command)
Remove the first occurrence of a command equal to the one provided as an argument from the collection
This method is an alias ofcommands.remove(command)
- Parameters:
command
- The command to be removed
-
printTree
public void printTree()
Print the result ofgetTree
- Specified by:
printTree
in interfaceExecutableCommands
- See Also:
ExecutableCommands.getTree()
-
getCommands
public java.util.ArrayList<ExecutableCommands> getCommands()
-
getCommand
public ExecutableCommands getCommand(int index)
-
getTree
public java.lang.String getTree()
Returns aString
containing a tree showing the hierarchy ofExecutableCommands
in this Collection- Specified by:
getTree
in interfaceExecutableCommands
- Returns:
- The command tree
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getTime
public int getTime()
Description copied from interface:ExecutableCommands
Get the default execution time of this Command- Specified by:
getTime
in interfaceExecutableCommands
- Returns:
- The default execution time of this Command
-
execBlocking
public void execBlocking()
Description copied from interface:ExecutableCommands
LikeExecutableCommands.exec()
but blocks the Thread until the Command has been executed- Specified by:
execBlocking
in interfaceExecutableCommands
-
execBlocking
public void execBlocking(int time)
Description copied from interface:ExecutableCommands
LikeExecutableCommands.exec(int)
but blocks the Thread until the Command has been executed- Specified by:
execBlocking
in interfaceExecutableCommands
- Parameters:
time
- The execution time in milliseconds
-
-