Package edu.wpi.first.util.struct
Class StructGenerator
java.lang.Object
edu.wpi.first.util.struct.StructGenerator
A utility class for procedurally generating
Structs from records and enums.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA utility for building schema syntax in a procedural manner. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidaddCustomStruct(Class<T> clazz, Struct<T> struct, boolean override) Add a custom struct to the structifier.
-
Method Details
-
addCustomStruct
Add a custom struct to the structifier.- Type Parameters:
T- The type the struct is for.- Parameters:
clazz- The class of the type.struct- The struct to add.override- Whether to override an existing struct. An existing struct could mean the type already has astructfield and implemntsStructSerializableor that the type is already in the custom struct map.
-
genRecord
Generates aStructfor the givenRecordclass. If aStructcannot be generated from theRecord, the errors encountered will be printed and a no-opStructwill be returned.- Type Parameters:
R- The type of the record.- Parameters:
recordClass- The class of the record.- Returns:
- The generated struct.
-
genEnum
Generates aStructfor the givenEnumclass. If aStructcannot be generated from theEnum, the errors encountered will be printed and a no-opStructwill be returned.- Type Parameters:
E- The type of the enum.- Parameters:
enumClass- The class of the enum.- Returns:
- The generated struct.
-