Class MockTunableBackend

java.lang.Object
org.wpilib.tunable.MockTunableBackend
All Implemented Interfaces:
AutoCloseable, TunableBackend

public class MockTunableBackend extends Object implements TunableBackend
A mock tunable backend for testing.
  • Constructor Details

    • MockTunableBackend

      public MockTunableBackend()
      Constructs a mock tunable backend.
  • Method Details

    • getTunable

      public TunableBase getTunable(String path)
      Gets a published tunable.
      Parameters:
      path - normalized path
      Returns:
      tunable
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getBoolean

      public boolean getBoolean(String path)
      Gets the value of a tunable.
      Parameters:
      path - normalized path
      Returns:
      value
    • getInteger

      public int getInteger(String path)
      Gets the value of a tunable.
      Parameters:
      path - normalized path
      Returns:
      value
    • getLong

      public long getLong(String path)
      Gets the value of a tunable.
      Parameters:
      path - normalized path
      Returns:
      value
    • getFloat

      public float getFloat(String path)
      Gets the value of a tunable.
      Parameters:
      path - normalized path
      Returns:
      value
    • getDouble

      public double getDouble(String path)
      Gets the value of a tunable.
      Parameters:
      path - normalized path
      Returns:
      value
    • getValue

      public <T> T getValue(String path, Class<T> cls)
      Gets the value of a tunable.
      Type Parameters:
      T - value type
      Parameters:
      path - normalized path
      cls - expected value class, superclass, or interface
      Returns:
      value
    • setBoolean

      public void setBoolean(String path, boolean value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setInt

      public void setInt(String path, int value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setLong

      public void setLong(String path, long value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setFloat

      public void setFloat(String path, float value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setDouble

      public void setDouble(String path, double value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setValue

      public <T> void setValue(String path, T value)
      Sets the value of a tunable.
      Type Parameters:
      T - value type
      Parameters:
      path - normalized path
      value - value
    • setArray

      public void setArray(String path, boolean[] value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setArray

      public void setArray(String path, int[] value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setArray

      public void setArray(String path, long[] value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setArray

      public void setArray(String path, float[] value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setArray

      public void setArray(String path, double[] value)
      Sets the value of a tunable.
      Parameters:
      path - normalized path
      value - value
    • setArray

      public <T> void setArray(String path, T[] value)
      Sets the value of a tunable.
      Type Parameters:
      T - array element type
      Parameters:
      path - normalized path
      value - value
    • publish

      public boolean publish(String path, TunableBase tunable)
      Description copied from interface: TunableBackend
      Publishes a tunable.

      Backend implementations must not throw from this method. Recoverable publication failures should be reported through TunableRegistry.reportWarning(String) and skipped.

      Specified by:
      publish in interface TunableBackend
      Parameters:
      path - normalized path
      tunable - the tunable
      Returns:
      true if the tunable was published, false otherwise
    • publishComplex

      public boolean publishComplex(String path, ComplexTunable tunable)
      Description copied from interface: TunableBackend
      Publishes a complex tunable.

      Backend implementations must not throw from this method. Recoverable publication failures should be reported through TunableRegistry.reportWarning(String) and skipped.

      Specified by:
      publishComplex in interface TunableBackend
      Parameters:
      path - normalized path
      tunable - the tunable
      Returns:
      true if the tunable was published, false otherwise
    • remove

      public void remove(String path)
      Description copied from interface: TunableBackend
      Removes a tunable.

      Backend implementations must not throw from this method.

      Specified by:
      remove in interface TunableBackend
      Parameters:
      path - normalized path
    • removePrefix

      public List<TunableBackend.PublishedTunable> removePrefix(String prefix)
      Description copied from interface: TunableBackend
      Removes all tunables under a prefix.

      Backend implementations must not throw from this method. The returned list must describe the tunables actually removed from the backend.

      Specified by:
      removePrefix in interface TunableBackend
      Parameters:
      prefix - normalized path prefix
      Returns:
      removed tunables
    • update

      public void update()
      Description copied from interface: TunableBackend
      Updates all tunable values and calls callbacks where appropriate.

      Backend implementations must not throw from this method. Recoverable update failures should be reported through TunableRegistry.reportWarning(String) and skipped so the robot loop and registry state can continue updating.

      Specified by:
      update in interface TunableBackend