Class MergeableCommand

  • All Implemented Interfaces:
    Command
    Direct Known Subclasses:
    ReflectionCommand, ScheduledHotswapCommand, WatchEventCommand

    public abstract class MergeableCommand
    extends Object
    implements Command
    Command that can merge multiple commands into a single execution.

    ${Scheduler.schedule()} compares existing scheduled commands with equlas() method and if the command exists, it is replaced by new command and timer is restarted - effectively forgetting firs command. This implementation provides a way to get all merged commands and process them in the execution. It is also an interface to override merge method to provide custom behaviour.

    For example - merge multiple MODIFY events into one, or if DELETE + CREATE events are scheduled, merge them into single MODIFY event.

    • Constructor Detail

      • MergeableCommand

        public MergeableCommand()
    • Method Detail

      • merge

        public Command merge​(Command other)
        Merge commands
        Parameters:
        other - the other command to merge to
        Returns:
        merge result, by default returns this instance.
      • getMergedCommands

        public List<Command> getMergedCommands()
      • popMergedCommands

        public List<Command> popMergedCommands()
        Return merged commands and clear internal list
        Returns:
        the list of merged commands