Package edu.wpi.first.util.struct
Class StructFetcher
java.lang.Object
edu.wpi.first.util.struct.StructFetcher
A utility class for fetching the assigned struct of existing classes. These are usually public,
static, and final properties with the Struct type.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends StructSerializable>
Optional<Struct<T>>fetchStruct
(Class<? extends T> clazz) Returns aStruct
for the givenStructSerializable
marked class.fetchStructDynamic
(Class<?> clazz) Returns aStruct
for the given class.
-
Method Details
-
fetchStruct
public static <T extends StructSerializable> Optional<Struct<T>> fetchStruct(Class<? extends T> clazz) Returns aStruct
for the givenStructSerializable
marked class. Due to the non-contractual nature of the marker this can fail. If thestruct
field could not be accessed for any reason, an emptyOptional
is returned.- Type Parameters:
T
- The type of the class.- Parameters:
clazz
- The class object to extract the struct from.- Returns:
- An optional containing the struct if it could be extracted.
-
fetchStructDynamic
Returns aStruct
for the given class. This does not do compile time checking that the class is aStructSerializable
. Whenever possible it is reccomended to usefetchStruct(Class)
.- Parameters:
clazz
- The class object to extract the struct from.- Returns:
- An optional containing the struct if it could be extracted.
-