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.

@FunctionalInterface public interface CommandGroup
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 CommandGroup beans then having Spring collect and provide them to the initializer of a Registry bean, which can then register them.
  • Method Details

    • commands

      @Pure Map<String,Command<?>> commands()
      Retrieves the commands contained in this group, keyed by their IDs.
      Returns:
      The ID-keyed command group.
      Implementation Requirements:
      As specified by the Pure annotation, this method should always return the same map instance for a given CommandGroup instance. Additionally, the map should be immutable.
    • ids

      @Pure default Set<@KeyFor("this.commands()") String> ids()
      Retrives the IDs of the commands in this group.
      Returns:
      The command IDs.
    • of

      @SideEffectFree static CommandGroup of(Map<String,? extends Command<?>> commands)
      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

      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.