-
- All Known Implementing Classes:
AliasCommands,ExitCommands,HelpCommands,HistoryCommands,JobCommands,OptionCommands,ScriptCommands,SimpleCommandGroup,VariableCommands
public interface CommandGroupA named group ofCommands for organization and discovery.CommandGroupprovides a pure discovery and organizational role. Execution and completion concerns belong toCommandDispatcher.Example:
CommandGroup group = new SimpleCommandGroup("myapp", echoCmd, greetCmd); dispatcher.addGroup(group);- Since:
- 4.0
- See Also:
Command,CommandDispatcher
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Commandcommand(java.lang.String name)Finds a command by name or alias.java.util.Collection<Command>commands()Returns all commands in this group.default booleanhasCommand(java.lang.String name)Returns whether this group contains a command with the given name or alias.default java.lang.Stringname()Returns the name of this command group.
-
-
-
Method Detail
-
name
default java.lang.String name()
Returns the name of this command group.The default implementation returns the simple class name.
- Returns:
- the group name
-
commands
java.util.Collection<Command> commands()
Returns all commands in this group.- Returns:
- the collection of commands, never null
-
command
default Command command(java.lang.String name)
Finds a command by name or alias.The default implementation scans
commands()for a match.- Parameters:
name- the command name or alias- Returns:
- the command, or null if not found
-
hasCommand
default boolean hasCommand(java.lang.String name)
Returns whether this group contains a command with the given name or alias.- Parameters:
name- the command name or alias- Returns:
- true if a matching command exists
-
-