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. For example, commands can be easily registered using Spring's
autowiring capabilities by grouping them into
CommandGroupbeans then having Spring collect and provide them to the initializer of aRegistrybean, which can then register them.
-
Method Summary
Modifier and TypeMethodDescriptioncommands()Retrieves the commands contained in this group, keyed by their IDs.ids()Retrives the IDs of the commands in this group.static CommandGroupmerge(Collection<CommandGroup> groups) Merges multiple command groups into one.static CommandGroupCreates a command group from the given mappings.
-
Method Details
-
commands
Retrieves the commands contained in this group, keyed by their IDs.- Returns:
- The ID-keyed command group.
- Implementation Requirements:
- As specified by the
Pureannotation, this method should always return the same map instance for a givenCommandGroupinstance. Additionally, the map should be immutable.
-
ids
Retrives the IDs of the commands in this group.- Returns:
- The command IDs.
-
of
Creates a command group from the given mappings.Changes made to the given map are not reflected in the returned instance.
- Parameters:
commands- The ID-command mappings to turn into a command group.- Returns:
- The equivalent command group.
-
merge
@SideEffectFree static CommandGroup merge(Collection<CommandGroup> groups) throws IllegalStateException Merges multiple command groups into one.- Parameters:
groups- The groups to merge.- Returns:
- A group that contains all the commands in the merged groups.
- Throws:
IllegalStateException- if there are duplicate command IDs.
-