public class KeyDispatchCodec<K,V> extends MapCodec<V>
MapCodec.MapCodecCodec<A>, MapCodec.ResultFunction<A>
MapDecoder.Implementation<A>
MapEncoder.Implementation<A>
Modifier | Constructor and Description |
---|---|
|
KeyDispatchCodec(String typeKey,
Codec<K> keyCodec,
(? super V) -> ? extends DataResult<? extends K> type,
(? super K) -> ? extends DataResult<? extends Codec<? extends V>> codec)
Assumes
codec(type(V)) is Codec<V> |
protected |
KeyDispatchCodec(String typeKey,
Codec<K> keyCodec,
(? super V) -> ? extends DataResult<? extends K> type,
(? super K) -> ? extends DataResult<? extends Decoder<? extends V>> decoder,
(? super V) -> ? extends DataResult<? extends Encoder<V>> encoder,
boolean assumeMap) |
Modifier and Type | Method and Description |
---|---|
<T> DataResult<V> |
decode(DynamicOps<T> ops,
MapLike<T> input)
Decodes an object from the given map of serialized entries.
|
<T> RecordBuilder<T> |
encode(V input,
DynamicOps<T> ops,
RecordBuilder<T> prefix)
Encodes the input into a set of record fields that are added to the given builder.
|
<T> Stream<T> |
keys(DynamicOps<T> ops)
Returns the set of keys this object defines or accepts, serialized to the provided form.
|
String |
toString() |
static <K,V> KeyDispatchCodec<K,V> |
unsafe(String typeKey,
Codec<K> keyCodec,
(? super V) -> ? extends DataResult<? extends K> type,
(? super K) -> ? extends DataResult<? extends Decoder<? extends V>> decoder,
(? super V) -> ? extends DataResult<? extends Encoder<V>> encoder)
Will assume that the result of all elements is a map
|
codec, dependent, deprecated, fieldOf, flatXmap, forGetter, mapResult, of, of, orElse, orElse, orElse, orElseGet, orElseGet, orElseGet, setPartial, stable, unit, unit, withLifecycle, xmap
compressor
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
ap, compressedDecode, compressor, decoder, flatMap, map
comap, compressedBuilder, compressor, encoder, flatComap, makeCompressedBuilder
forStrings
protected KeyDispatchCodec(String typeKey, Codec<K> keyCodec, (? super V) -> ? extends DataResult<? extends K> type, (? super K) -> ? extends DataResult<? extends Decoder<? extends V>> decoder, (? super V) -> ? extends DataResult<? extends Encoder<V>> encoder, boolean assumeMap)
public static <K,V> KeyDispatchCodec<K,V> unsafe(String typeKey, Codec<K> keyCodec, (? super V) -> ? extends DataResult<? extends K> type, (? super K) -> ? extends DataResult<? extends Decoder<? extends V>> decoder, (? super V) -> ? extends DataResult<? extends Encoder<V>> encoder)
public <T> DataResult<V> decode(DynamicOps<T> ops, MapLike<T> input)
MapDecoder
DataResult
.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(V input, DynamicOps<T> ops, RecordBuilder<T> prefix)
MapEncoder
T
- 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