Class LogTableUtil
java.lang.Object
com.stuypulse.robot.util.talonfx.logged.LogTableUtil
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TGets a value from aLogTablewith the given key, automatically handling the type of the value based on the provided default value.private static ObjectGets an array value from aLogTable, dispatching to the corresponding array overload.private static <E extends Enum<E>>
Eprivate static <E extends Enum<E>>
E[]getEnumArray(org.littletonrobotics.junction.LogTable table, String key, Enum<?>[] defaultValue) private static booleanisSupportedArrayType(Object value) static booleanisSupportedType(Object value) Returns true if the value is a supported type for logging, false otherwise.static voidPuts a value into aLogTablewith the given key, automatically handling the type of the value.private static voidPuts an array value into aLogTable, dispatching to the corresponding array overload.private static <E extends Enum<E>>
voidprivate static <E extends Enum<E>>
voidputEnumArray(org.littletonrobotics.junction.LogTable table, String key, Enum<?>[] value)
-
Constructor Details
-
LogTableUtil
private LogTableUtil()
-
-
Method Details
-
put
Puts a value into aLogTablewith the given key, automatically handling the type of the value.- Parameters:
table- theLogTableto put the value intokey- The key where the value will be stored.value- The value to store in theLogTable. If it's not a supported type, it will be converted to a string.
-
putArray
-
get
Gets a value from aLogTablewith 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- TheLogTableto 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 theLogTable.- Returns:
- The value from the
LogTableif 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 aLogTable, dispatching to the corresponding array overload. Types with no array overload such asMeasureor boxed wrapper types aren't replayable, so the default array is returned back. -
putEnum
-
getEnum
-
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
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
-