Class RecordField<Type, FieldType>

java.lang.Object
com.hypixel.hytale.codec.record.RecordField<Type, FieldType>
Type Parameters:
Type - the record type this component belongs to.
FieldType - the component type.

public final class RecordField<Type, FieldType> extends Object
A single component of a RecordCodec.

The accessor reads the component from an existing instance when encoding. When decoding the value is placed into the constructor argument array at index, which matches the order the component was appended to the builder. The validator, documentation, and metadata surface mirrors BuilderField; record fields do not carry the per-field version-range or inheritance support a builder field has.

  • Method Details

    • getCodec

      @Nonnull public KeyedCodec<FieldType> getCodec()
    • getDocumentation

      @Nullable public String getDocumentation()
    • hasNonNullValidator

      public boolean hasNonNullValidator()
    • isPrimitive

      public boolean isPrimitive()
    • encode

      public void encode(@Nonnull org.bson.BsonDocument document, Type t, @Nonnull ExtraInfo extraInfo)
    • decode

      public void decode(@Nonnull org.bson.BsonValue bsonValue, @Nonnull Object[] args, @Nonnull ExtraInfo extraInfo)
      Decodes bsonValue (the value already fetched for this field's key) and stores the result in args at this field's constructor position. The args array is shared across all of a record's fields and is passed to the constructor once decoding completes.
    • decodeJson

      public void decodeJson(@Nonnull RawJsonReader reader, @Nonnull Object[] args, @Nonnull ExtraInfo extraInfo) throws IOException
      Decodes the next JSON value from reader and stores it in args at this field's constructor position. The caller is expected to have pushed this field's key already.
      Throws:
      IOException
    • validate

      public void validate(Type t, @Nonnull ExtraInfo extraInfo)
    • updateSchema

      public void updateSchema(@Nonnull SchemaContext context, @Nonnull Schema target)
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object