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 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 Details

    • commands

      @Pure Collection<Command<?>> 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 given CommandGroup instance. Additionally, the collection should be immutable.
    • of

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

      @SideEffectFree static CommandGroup of(Command<?>... commands)
      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.