edu.wpi.first.wpilibj.command

## Class InstantCommand

- java.lang.Object
- - edu.wpi.first.wpilibj.command.Command
  - - edu.wpi.first.wpilibj.command.InstantCommand

- All Implemented Interfaces:
    NamedSendable, Sendable
  Direct Known Subclasses:
    PrintCommand, StartCommand

      public class InstantCommand
      extends Command

  This command will execute once, then finish immediately afterward.

  Subclassing `InstantCommand` is shorthand for returning true from `isFinished`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InstantCommand()`
    `InstantCommand(java.lang.String name)` Creates a new `InstantCommand` with the given name.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `isFinished()` Returns whether this command is finished.

    - ### Methods inherited from class edu.wpi.first.wpilibj.command.Command

      `cancel, clearRequirements, doesRequire, end, execute, getGroup, getName, getSmartDashboardType, initialize, initTable, interrupted, isCanceled, isInterruptible, isRunning, isTimedOut, requires, setInterruptible, setRunWhenDisabled, setTimeout, start, timeSinceInitialized, toString, willRunWhenDisabled`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### InstantCommand

          public InstantCommand()

    - #### InstantCommand

          public InstantCommand(java.lang.String name)

      Creates a new `InstantCommand` with the given name.
      Parameters:
        `name` - the name for this command

  - ### Method Detail

    - #### 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()`