Class TunableInt

java.lang.Object
org.wpilib.tunable.TunableBase
org.wpilib.tunable.TunableInt
All Implemented Interfaces:
IntConsumer, IntSupplier

public abstract class TunableInt extends TunableBase implements IntSupplier, IntConsumer
A tunable integer.
  • Constructor Details

    • TunableInt

      protected TunableInt(TunableConfig config)
      Constructs a tunable integer.
      Parameters:
      config - tunable config
    • TunableInt

      protected TunableInt(TunableConfig config, boolean supportsChangeNotification)
      Constructs a tunable integer.
      Parameters:
      config - tunable config
      supportsChangeNotification - whether the tunable notifies backends when it changes
  • Method Details

    • create

      public static TunableInt create()
      Creates a tunable integer with the initial value of 0.
      Returns:
      a tunable integer
    • create

      public static TunableInt create(int initialValue)
      Creates a tunable integer with the given initial value.
      Parameters:
      initialValue - initial value
      Returns:
      a tunable integer
    • create

      public static TunableInt create(IntSupplier getter, IntConsumer setter)
      Creates a tunable integer with the given getter and setter.

      The getter and setter must not throw.

      Parameters:
      getter - getter for the tunable value
      setter - setter for the tunable value
      Returns:
      a tunable integer
    • createConfig

      public static TunableInt createConfig(TunableConfig config)
      Creates a tunable integer with the given config and an initial value of 0.
      Parameters:
      config - tunable config
      Returns:
      a tunable integer
    • createConfig

      public static TunableInt createConfig(int initialValue, TunableConfig config)
      Creates a tunable integer with the given initial value and config.
      Parameters:
      initialValue - initial value
      config - tunable config
      Returns:
      a tunable integer
    • createConfig

      public static TunableInt createConfig(IntSupplier getter, IntConsumer setter, TunableConfig config)
      Creates a tunable integer with the given getter, setter, and config.

      The getter and setter must not throw.

      Parameters:
      getter - getter for the tunable value
      setter - setter for the tunable value
      config - tunable config
      Returns:
      a tunable integer
    • set

      public abstract void set(int value)
      Sets the value.

      Implementations must not throw.

      Parameters:
      value - value
    • get

      public abstract int get()
      Gets the value.

      Implementations must not throw.

      Returns:
      value
    • getAsInt

      public int getAsInt()
      Specified by:
      getAsInt in interface IntSupplier
    • accept

      public void accept(int value)
      Specified by:
      accept in interface IntConsumer