Class LogTableUtil

java.lang.Object
com.stuypulse.robot.util.talonfx.logged.LogTableUtil

public final class LogTableUtil extends Object

Log Table Utility

Utility methods for reading and writing dynamically typed values to and from a LogTable.

This centralizes type handling without having to duplicate the same if else logic in multiple places.

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    get(org.littletonrobotics.junction.LogTable table, String key, T defaultValue)
    Gets a value from a LogTable with the given key, automatically handling the type of the value based on the provided default value.
    private static Object
    getArray(org.littletonrobotics.junction.LogTable table, String key, Object defaultArray)
    Gets an array value from a LogTable, dispatching to the corresponding array overload.
    private static <E extends Enum<E>>
    E
    getEnum(org.littletonrobotics.junction.LogTable table, String key, Enum<?> defaultValue)
     
    private static <E extends Enum<E>>
    E[]
    getEnumArray(org.littletonrobotics.junction.LogTable table, String key, Enum<?>[] defaultValue)
     
    private static boolean
     
    static boolean
    Returns true if the value is a supported type for logging, false otherwise.
    static void
    put(org.littletonrobotics.junction.LogTable table, String key, Object value)
    Puts a value into a LogTable with the given key, automatically handling the type of the value.
    private static void
    putArray(org.littletonrobotics.junction.LogTable table, String key, Object array)
    Puts an array value into a LogTable, dispatching to the corresponding array overload.
    private static <E extends Enum<E>>
    void
    putEnum(org.littletonrobotics.junction.LogTable table, String key, Enum<?> value)
     
    private static <E extends Enum<E>>
    void
    putEnumArray(org.littletonrobotics.junction.LogTable table, String key, Enum<?>[] value)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • put

      public static void put(org.littletonrobotics.junction.LogTable table, String key, Object value)
      Puts a value into a LogTable with the given key, automatically handling the type of the value.
      Parameters:
      table - the LogTable to put the value into
      key - The key where the value will be stored.
      value - The value to store in the LogTable. If it's not a supported type, it will be converted to a string.
    • putArray

      private static void putArray(org.littletonrobotics.junction.LogTable table, String key, Object array)
      Puts an array value into a LogTable, dispatching to the corresponding array overload. Falls back to a String[] for element types with no array overload such as a Measure or boxed wrapper types.
    • get

      public static <T> T get(org.littletonrobotics.junction.LogTable table, String key, T defaultValue)
      Gets a value from a LogTable with the given key, automatically handling the type of the value based on the provided default value.
      Type Parameters:
      T - The type of the value.
      Parameters:
      table - The LogTable to get the value from.
      key - The key where the valid is stored.
      defaultValue - The default value to return if the key does not exist in the LogTable .
      Returns:
      The value from the LogTable if it exists, otherwise the default value.
    • getArray

      private static Object getArray(org.littletonrobotics.junction.LogTable table, String key, Object defaultArray)
      Gets an array value from a LogTable, dispatching to the corresponding array overload. Types with no array overload such as Measure or boxed wrapper types aren't replayable, so the default array is returned back.
    • putEnum

      private static <E extends Enum<E>> void putEnum(org.littletonrobotics.junction.LogTable table, String key, Enum<?> value)
    • getEnum

      private static <E extends Enum<E>> E getEnum(org.littletonrobotics.junction.LogTable table, String key, Enum<?> defaultValue)
    • putEnumArray

      private static <E extends Enum<E>> void putEnumArray(org.littletonrobotics.junction.LogTable table, String key, Enum<?>[] value)
    • getEnumArray

      private static <E extends Enum<E>> E[] getEnumArray(org.littletonrobotics.junction.LogTable table, String key, Enum<?>[] defaultValue)
    • isSupportedType

      public static boolean isSupportedType(Object value)
      Returns true if the value is a supported type for logging, false otherwise.
      Parameters:
      value - The value to check for logging support.
      Returns:
      true if the value is a supported type for logging, false otherwise.
    • isSupportedArrayType

      private static boolean isSupportedArrayType(Object value)