Interface SerialCodec<T>
- Type Parameters:
T- the type
Written by the Gradle plugin for every type annotated SerialType. A hand-written one
registered for the same type replaces it, which is the escape hatch for a shape the generator
refuses.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionReturns the class hierarchy's descriptors, most derived first.readData(SerialSource source) Reads every field value back and builds the object.voidwriteData(T value, SerialSink sink) Writes every field value.
-
Method Details
-
descriptors
List<SerialDescriptor> descriptors()Returns the class hierarchy's descriptors, most derived first.The format writes the chain so a reader knows which fields belong to which level. A class whose superclass is not serializable has one entry.
- Returns:
- the class hierarchy's descriptors, most derived first
-
writeData
Writes every field value.Most super class first, and within each class the order of its
SerialDescriptor.fields. That is the order the format fixes, so the generator emits the calls and this does not choose.- Parameters:
value- the objectsink- where the values go
-
readData
Reads every field value back and builds the object.The instance is built from the values rather than allocated and filled, because there is no
Unsafeon this platform to allocate one without running a constructor. A record is built through its canonical constructor and anything else through its no-argument constructor.- Parameters:
source- where the values come from- Returns:
- the object
-