Class CommandsAndHandlers

java.lang.Object
com.vaadin.signals.impl.CommandsAndHandlers

public class CommandsAndHandlers extends Object
A list of signal commands together with their result handlers.
  • Constructor Details

    • CommandsAndHandlers

      public CommandsAndHandlers()
      Creates a new empty command list.
    • CommandsAndHandlers

      public CommandsAndHandlers(List<SignalCommand> commands, Map<Id,Consumer<CommandResult>> resultHandlers)
      Creates a new command list with the given commands and result handlers.
      Parameters:
      commands - the commands to use, not null
      resultHandlers - the result handlers to use, not null
    • CommandsAndHandlers

      public CommandsAndHandlers(SignalCommand command, Consumer<CommandResult> resultHandler)
      Creates a new command list with a single command and optional result handler.
      Parameters:
      command - the command to use, not null
      resultHandler - the result handler to use, or null to not use a result handler
  • Method Details

    • removeHandledCommands

      public void removeHandledCommands(Collection<Id> handledCommandIds)
      Removes commands based on a collection of handled commands. Note that the corresponding result handlers are not removed but there's instead an assumption that the caller will invoke notifyResultHandlers(Map) separately.
      Parameters:
      handledCommandIds - a collection of handled commands ids, not null
    • notifyResultHandlers

      public void notifyResultHandlers(Map<Id,CommandResult> results)
      Notifies and removes result handlers for the given results.
      Parameters:
      results - a map of command results, not null
    • notifyResultHandlers

      public void notifyResultHandlers(Map<Id,CommandResult> results, List<SignalCommand> commandOrder)
      Notifies and removes result handlers for the given results in the given order. Commands in the order that have no corresponding result are ignored.
      Parameters:
      results - the map of command results, not null
      commandOrder - a list of commands in the order the results should be applied.
    • getCommands

      public List<SignalCommand> getCommands()
      Gets an unmodifiable view of the commands.
      Returns:
      an unmodifiable list of commands, not null
    • getResultHandlers

      public Map<Id,Consumer<CommandResult>> getResultHandlers()
      Gets an unmodifiable map of the result handlers.
      Returns:
      an unmodifiable map of result handlers, not null
    • add

      public void add(CommandsAndHandlers other)
      Adds another collection of commands and handlers to this one.
      Parameters:
      other - the instance to import entries from, not null
    • isEmpty

      public boolean isEmpty()
      Checks whether there are any commands in this list.
      Returns:
      true if there are no commands in this list, false if there are commands