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 aStructfor the givenStructSerializablemarked class.fetchStructDynamic(Class<?> clazz) Returns aStructfor the given class.
-
Method Details
-
fetchStruct
public static <T extends StructSerializable> Optional<Struct<T>> fetchStruct(Class<? extends T> clazz) Returns aStructfor the givenStructSerializablemarked class. Due to the non-contractual nature of the marker this can fail. If thestructfield could not be accessed for any reason, an emptyOptionalis 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 aStructfor 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.
-