Class RecordCodec<T>

java.lang.Object
com.hypixel.hytale.codec.record.RecordCodec<T>
Type Parameters:
T - the type this codec can encode and decode.
All Implemented Interfaces:
Codec<T>, RawJsonCodec<T>, SchemaConvertable<T>, ValidatableCodec<T>

public final class RecordCodec<T> extends Object implements Codec<T>, ValidatableCodec<T>
A Codec for immutable types such as record classes.

Unlike BuilderCodec, this codec never mutates the target instance. Each field is decoded into a constructor argument array in the order the fields were appended, then the type is built once by invoking the supplied constructor. The same fields are read back through their accessors when encoding.

Build one with builder(Class); each append refines the builder type so the final build is checked against the constructor, for example .build(Point::new). Append order must match the constructor parameter order. Pass a Validator to append to attach a single field validator, or a RecordField.Options consumer for multiple validators, documentation, or metadata. Records with more than eight components continue with RecordCodec.RawBuilder and finish with RecordCodec.AbstractBuilder.buildRaw(Function).