public class OptionalFieldCodec<A> extends MapCodec<Optional<A>>
MapCodec.MapCodecCodec<A>, MapCodec.ResultFunction<A>MapDecoder.Implementation<A>MapEncoder.Implementation<A>| Constructor and Description |
|---|
OptionalFieldCodec(String name,
Codec<A> elementCodec) |
| Modifier and Type | Method and Description |
|---|---|
<T> DataResult<Optional<A>> |
decode(DynamicOps<T> ops,
MapLike<T> input)
Decodes an object from the given map of serialized entries.
|
<T> RecordBuilder<T> |
encode(Optional<A> input,
DynamicOps<T> ops,
RecordBuilder<T> prefix)
Encodes the input into a set of record fields that are added to the given builder.
|
boolean |
equals(Object o) |
int |
hashCode() |
<T> Stream<T> |
keys(DynamicOps<T> ops)
Returns the set of keys this object defines or accepts, serialized to the provided form.
|
String |
toString() |
codec, dependent, deprecated, fieldOf, flatXmap, forGetter, mapResult, of, of, orElse, orElse, orElse, orElseGet, orElseGet, orElseGet, setPartial, stable, unit, unit, withLifecycle, xmapcompressorclone, finalize, getClass, notify, notifyAll, wait, wait, waitap, compressedDecode, compressor, decoder, flatMap, mapcomap, compressedBuilder, compressor, encoder, flatComap, makeCompressedBuilderforStringspublic <T> DataResult<Optional<A>> decode(DynamicOps<T> ops, MapLike<T> input)
MapDecoderDataResult.T - The type of the serialized form.ops - The DynamicOps instance defining the serialized form.input - A map or maplike object containing the serialized entries.DataResult containing the decoded object, or an error if no object could be decoded.MapDecoder.compressedDecode(DynamicOps, Object)public <T> RecordBuilder<T> encode(Optional<A> input, DynamicOps<T> ops, RecordBuilder<T> prefix)
MapEncoderT - The type of the serialized form.input - The value to serialize.ops - The DynamicOps instance defining the serialized form.prefix - A RecordBuilder to add the serialized fields to.public <T> Stream<T> keys(DynamicOps<T> ops)
Keyable