Class FieldBuilder<T>

java.lang.Object
com.github.darksoulq.abyssallib.common.serialization.FieldBuilder<T>
Type Parameters:
T - The type of the field's value.

public class FieldBuilder<T> extends Object
A builder for defining a field within a structured record codec.
  • Constructor Details

    • FieldBuilder

      public FieldBuilder(String name, Codec<T> codec, boolean optional, T defaultValue)
      Constructs the intermediary field builder.
      Parameters:
      name - The structural identifier for the field map key.
      codec - The target codec resolving the data.
      optional - Whether the field's absence should be tolerated.
      defaultValue - The fallback primitive value to utilize if missing.
  • Method Details

    • alias

      public FieldBuilder<T> alias(String... alternatives)
      Registers alternative string paths to parse seamlessly mapping backward-compatibility configurations efficiently.
      Parameters:
      alternatives - Collection encapsulating legacy iteration node parsing path parameters cleanly.
      Returns:
      Chaining reference modifying parent structural definitions properly mapped safely.
    • forGetter

      public <O> RecordField<O,T> forGetter(Function<O,T> getter)
      Binds this field definition to a getter function of the parent object.
      Type Parameters:
      O - The parent object type.
      Parameters:
      getter - The function used to retrieve the field's value from the parent.
      Returns:
      A completed record field definition ready for use in a RecordBuilder.
    • forGetter

      public <O> RecordField<O,T> forGetter(Class<O> type, Function<O,T> getter)
      Binds this field definition to a getter function of the parent object, anchoring the type context.
      Type Parameters:
      O - The parent object type.
      Parameters:
      type - The class literal of the parent object.
      getter - The function used to retrieve the field's value from the parent.
      Returns:
      A completed record field definition ready for use in a RecordBuilder.