Class ConditionalCommand

    • Constructor Detail

      • ConditionalCommand

        public ConditionalCommand​(Command onTrue)
        Creates a new ConditionalCommand with given onTrue and onFalse Commands.

        Users of this constructor should also override condition().

        Parameters:
        onTrue - The Command to execute if condition() returns true
      • ConditionalCommand

        public ConditionalCommand​(Command onTrue,
                                  Command onFalse)
        Creates a new ConditionalCommand with given onTrue and onFalse Commands.

        Users of this constructor should also override condition().

        Parameters:
        onTrue - The Command to execute if condition() returns true
        onFalse - The Command to execute if condition() returns false
      • ConditionalCommand

        public ConditionalCommand​(String name,
                                  Command onTrue)
        Creates a new ConditionalCommand with given name and onTrue and onFalse Commands.

        Users of this constructor should also override condition().

        Parameters:
        name - the name for this command group
        onTrue - The Command to execute if condition() returns true
      • ConditionalCommand

        public ConditionalCommand​(String name,
                                  Command onTrue,
                                  Command onFalse)
        Creates a new ConditionalCommand with given name and onTrue and onFalse Commands.

        Users of this constructor should also override condition().

        Parameters:
        name - the name for this command group
        onTrue - The Command to execute if condition() returns true
        onFalse - The Command to execute if condition() returns false
    • Method Detail

      • condition

        protected abstract boolean condition()
        The Condition to test to determine which Command to run.
        Returns:
        true if m_onTrue should be run or false if m_onFalse should be run.
      • _initialize

        protected void _initialize()
        Calls condition() and runs the proper command.
      • _cancel

        protected void _cancel()
      • isFinished

        protected boolean isFinished()
        Description copied from class: Command
        Returns whether this command is finished. If it is, then the command will be removed and end() will be called.

        It may be useful for a team to reference the isTimedOut() method for time-sensitive commands.

        Returning false will result in the command never ending automatically. It may still be cancelled manually or interrupted by another command. Returning true will result in the command executing once and finishing immediately. We recommend using InstantCommand for this.

        Specified by:
        isFinished in class Command
        Returns:
        whether this command is finished.
        See Also:
        isTimedOut()
      • _interrupted

        protected void _interrupted()