A
- The type that this MapDecoder
deserializes.public interface MapDecoder<A> extends Keyable
A MapDecoder
is a specialization of a Decoder
that operates on some defined set of record keys.
While a MapDecoder
does not implement Decoder
, any MapDecoder
may be turned into a
Decoder
by calling the decoder()
method.
Implementations of MapDecoder
are immutable once created. The methods defined in this interface never
mutate the decoder in a way visible to the outside.
Decoder
,
MapCodec
Modifier and Type | Interface and Description |
---|---|
static class |
MapDecoder.Implementation<A>
A class that implements both
MapDecoder and Compressable . |
Modifier and Type | Method and Description |
---|---|
default <E> MapDecoder<E> |
ap(MapDecoder<(? super A) -> ? extends E> decoder)
Applies a transformation decoded from the given map decoder to decoded values.
|
default <T> DataResult<A> |
compressedDecode(DynamicOps<T> ops,
T input)
Decodes an object from the given serialized form.
|
<T> KeyCompressor<T> |
compressor(DynamicOps<T> ops)
Returns the
KeyCompressor used to associate record keys with indices. |
<T> DataResult<A> |
decode(DynamicOps<T> ops,
MapLike<T> input)
Decodes an object from the given map of serialized entries.
|
default Decoder<A> |
decoder()
Returns a
Decoder that implements the operations defined in this map decoder. |
default <B> MapDecoder<B> |
flatMap((? super A) -> ? extends DataResult<? extends B> function)
Transforms this map decoder to operate on a different type using the given partial mapping function.
|
default <B> MapDecoder<B> |
map((? super A) -> ? extends B function)
Transforms this map decoder to operate on a different type using the given mapping function.
|
default MapDecoder<A> |
withLifecycle(Lifecycle lifecycle)
Sets the
Lifecycle of the results this map decoder deserializes. |
forStrings, keys
<T> DataResult<A> decode(DynamicOps<T> ops, MapLike<T> input)
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.compressedDecode(DynamicOps, Object)
default <T> DataResult<A> compressedDecode(DynamicOps<T> ops, T input)
DynamicOps
uses compressed keys, the input
should also contain compressed keys. Likewise, if the DynamicOps
does not use compressed keys, the input
should also not contain compressed keys.MapLike
that is then passed to decode(DynamicOps, MapLike)
.T
- The type of the serialized form.ops
- The DynamicOps
instance defining the serialized form.input
- The serialized value that contains the record data to deserialize.DataResult
containing the decoded object, or an error if no object could be decoded.<T> KeyCompressor<T> compressor(DynamicOps<T> ops)
KeyCompressor
used to associate record keys with indices.T
- The type of the serialized form.ops
- The DynamicOps
instance defining the serialized form.KeyCompressor
for this map decoder.default Decoder<A> decoder()
Decoder
that implements the operations defined in this map decoder.Decoder
that implements the Decoder.decode(DynamicOps, Object)
method to call decode(DynamicOps, MapLike)
.default <B> MapDecoder<B> flatMap((? super A) -> ? extends DataResult<? extends B> function)
MapDecoder.Implementation
that wraps this map decoder.B
- The new type.function
- A function from the current type to the new type.default <B> MapDecoder<B> map((? super A) -> ? extends B function)
MapDecoder.Implementation
that wraps this map decoder.B
- The new type.function
- A function from the current type to the new type.default <E> MapDecoder<E> ap(MapDecoder<(? super A) -> ? extends E> decoder)
MapDecoder
.MapDecoder.Implementation
that wraps this map decoder.E
- The new type.decoder
- A decoder that deserializes mapping functions.map(Function)
,
Applicative
default MapDecoder<A> withLifecycle(Lifecycle lifecycle)
Lifecycle
of the results this map decoder deserializes.MapDecoder.Implementation
that wraps this map decoder.lifecycle
- The lifecycle to use.