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 multipleExecutableCommandsinto 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 theExecutableCommandscontained in the array
-
Method Summary
Modifier and Type Method Description voidadd(ExecutableCommands command)Add anExecutableCommandto the commands contained in thisCollectionbooleanequals(java.lang.Object obj)voidexec()Call theexec()methods of all contained commandsvoidexec(int time)Call theexec(int)methods of all contained commands with the provided time as the argumentvoidexecBlocking()LikeExecutableCommands.exec()but blocks the Thread until the Command has been executedvoidexecBlocking(int time)LikeExecutableCommands.exec(int)but blocks the Thread until the Command has been executedExecutableCommandsgetCommand(int index)java.util.ArrayList<ExecutableCommands>getCommands()intgetTime()Get the default execution time of this Commandjava.lang.StringgetTree()Returns aStringcontaining a tree showing the hierarchy ofExecutableCommandsin this CollectionvoidprintTree()Print the result ofgetTreevoidremove(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 theExecutableCommandscontained in the array- Parameters:
commands- An array of ExecutableCommands
-
-
Method Detail
-
exec
public void exec()
Call theexec()methods of all contained commands- Specified by:
execin 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:
execin interfaceExecutableCommands- Parameters:
time- Argument forExecutableCommands.exec(int)- See Also:
exec()
-
add
public void add(ExecutableCommands command)
Add anExecutableCommandto 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:
printTreein 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 aStringcontaining a tree showing the hierarchy ofExecutableCommandsin this Collection- Specified by:
getTreein interfaceExecutableCommands- Returns:
- The command tree
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getTime
public int getTime()
Description copied from interface:ExecutableCommandsGet the default execution time of this Command- Specified by:
getTimein interfaceExecutableCommands- Returns:
- The default execution time of this Command
-
execBlocking
public void execBlocking()
Description copied from interface:ExecutableCommandsLikeExecutableCommands.exec()but blocks the Thread until the Command has been executed- Specified by:
execBlockingin interfaceExecutableCommands
-
execBlocking
public void execBlocking(int time)
Description copied from interface:ExecutableCommandsLikeExecutableCommands.exec(int)but blocks the Thread until the Command has been executed- Specified by:
execBlockingin interfaceExecutableCommands- Parameters:
time- The execution time in milliseconds
-
-