Class SmartNumber

java.lang.Object
java.lang.Number
com.stuypulse.stuylib.network.SmartNumber
All Implemented Interfaces:
IStream, Serializable, DoubleSupplier

public final class SmartNumber extends Number implements IStream
SmartNumber works as a wrapper for values on SmartDashboard. The idea for this class was to make getting values on SmartDashboard easier by making them variables that you know were initialized.
See Also:
  • Constructor Details

    • SmartNumber

      public SmartNumber(String id, double value)
      Creates a SmartNumber with the element name and a default value. The value on SmartDashboard will be reset to the default value on initialization.
      Parameters:
      id - the name of the number on SmartDashboard
      value - the default / initialization value for the value
  • Method Details

    • get

      public double get()
      Specified by:
      get in interface IStream
      Returns:
      the value of the number from SmartDashboard
    • getDefault

      public double getDefault()
      Returns:
      the default value of the number
    • set

      public void set(Number value)
      Parameters:
      value - what the value on SmartDashboard will be set to
    • reset

      public void reset()
      Resets the value on SmartDashboard to the default value
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
      Returns:
      the value of the number from SmartDashboard (casted to a double)
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
      Returns:
      the value of the number from SmartDashboard (casted to a float)
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
      Returns:
      the value of the number from SmartDashboard (casted to a int)
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
      Returns:
      the value of the number from SmartDashboard (casted to a long)
    • setNumber

      public static Number setNumber(Number oldNumber, Number newNumber)
      This function checks to see if oldNumber is a SmartNumber, if it is, then it sets the oldNumber to newNumber and returns the oldNumber. Otherwise, it just returns newNumber.
      Parameters:
      oldNumber - number that is being replaced
      newNumber - number representing the value of the new number
      Returns:
      if oldNumber is not a SmartNumber, then this function will return newNumber. If oldNumber is a SmartNumber, then this function will return oldNumber with its value set to newNumber