Package edu.wpi.first.util.struct
Class StructGenerator
java.lang.Object
edu.wpi.first.util.struct.StructGenerator
A utility class for procedurally generating
Struct
s from records and enums.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A utility for building schema syntax in a procedural manner. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
addCustomStruct
(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 astruct
field and implemntsStructSerializable
or that the type is already in the custom struct map.
-
genRecord
Generates aStruct
for the givenRecord
class. If aStruct
cannot be generated from theRecord
, the errors encountered will be printed and a no-opStruct
will be returned.- Type Parameters:
R
- The type of the record.- Parameters:
recordClass
- The class of the record.- Returns:
- The generated struct.
-
genEnum
Generates aStruct
for the givenEnum
class. If aStruct
cannot be generated from theEnum
, the errors encountered will be printed and a no-opStruct
will be returned.- Type Parameters:
E
- The type of the enum.- Parameters:
enumClass
- The class of the enum.- Returns:
- The generated struct.
-