Package dev.sympho.modular_commands.api
Interface CommandGroup
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Encapsulates a group of commands.
- Since:
- 1.0
- Version:
- 1.0
- API Note:
- This interface is provided primarily to facilitate the use of dependency-injection
(IoC) frameworks when commands must be created in distinct groups (i.e. cannot be
created individually) and the framework does not have a native way of merging
collections. In those cases, this type can be used to encapsulate these groups,
which can then be combined using
merge(Collection)
.
-
Method Summary
Modifier and TypeMethodDescriptionCollection<Command<?>>
commands()
Retrieves the commands contained in this group.static CommandGroup
merge
(Collection<CommandGroup> groups) Merges multiple command groups into one.static CommandGroup
Creates a command group from the given commands.static CommandGroup
of
(Collection<? extends Command<?>> commands) Creates a command group from the given commands.
-
Method Details
-
commands
Retrieves the commands contained in this group.- Returns:
- The command group.
- Implementation Requirements:
- As specified by the
Pure
annotation, this method should always return the same instance for a givenCommandGroup
instance. Additionally, the collection should be immutable.
-
of
Creates a command group from the given commands.Changes made to the given collection are not reflected in the returned instance.
- Parameters:
commands
- The commands to turn into a command group.- Returns:
- The equivalent command group.
-
of
Creates a command group from the given commands.- Parameters:
commands
- The commands to turn into a command group.- Returns:
- The equivalent command group.
-
merge
Merges multiple command groups into one.- Parameters:
groups
- The groups to merge.- Returns:
- A group that contains all the commands in the merged groups.
-