Class MapCodec<K,V>
java.lang.Object
dev.siroshun.codec4j.api.codec.collection.MapCodec<K,V>
- Type Parameters:
K- the type of the keyV- the type of the value
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordADecodeErrorwhen an entry is duplicated during decoding into a map that does not allow duplicates. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> @NotNull MapCodec <K, V> create(@NotNull EntryProcessor<K, V, Map.Entry<K, V>, Map<K, V>> processor) Creates aMapCodecwith the specifiedEntryProcessor.@NotNull dev.siroshun.jfun.result.Result<Map<K, V>, DecodeError> Decodes the data from the providedIn.<O> @NotNull dev.siroshun.jfun.result.Result<O, EncodeError> static <K,V> @NotNull MapCodec <K, V> static <K,V> @NotNull MapCodec <K, V> Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.siroshun.codec4j.api.codec.Codec
flatXmap, named, toCollectionCodec, toFieldCodec, toListCodec, toMapCodecAsKey, toMapCodecAsValue, toSetCodec, xmapMethods inherited from interface dev.siroshun.codec4j.api.decoder.Decoder
catchError, flatMap, inspect, map, toListDecoder, toOptionalFieldDecoder, toRequiredFieldDecoder, toSetDecoder, toSetDecoder, toSupplyingFieldDecoderMethods inherited from interface dev.siroshun.codec4j.api.encoder.Encoder
comap, flatComap, toCollectionEncoder, toFieldEncoder, toFieldEncoder
-
Method Details
-
map
-
map
@Contract("_, _, _, _, _ -> new") @NotNull public static <K,V> @NotNull MapCodec<K,V> map(@NotNull @NotNull Codec<K> keyCodec, @NotNull @NotNull Codec<V> valueCodec, @NotNull @NotNull Supplier<Map<K, V>> factory, boolean allowDuplicatedKey, @NotNull @NotNull UnaryOperator<Map<K, V>> finalizer) -
create
@Contract("_ -> new") @NotNull public static <K,V> @NotNull MapCodec<K,V> create(@NotNull @NotNull EntryProcessor<K, V, Map.Entry<K, V>, Map<K, V>> processor) Creates aMapCodecwith the specifiedEntryProcessor.- Type Parameters:
K- the type of the keyV- the type of the value- Parameters:
processor- theEntryProcessor- Returns:
- a
MapCodec
-
decode
@NotNull public @NotNull dev.siroshun.jfun.result.Result<Map<K,V>, decodeDecodeError> (@NotNull @NotNull In in) Description copied from interface:DecoderDecodes the data from the providedIn.- Specified by:
decodein interfaceDecoder<K>- Parameters:
in- theInfor reading the data to decode- Returns:
- a result containing the decoded data, or a
DecodeErrorif the operation failed
-
encode
@NotNull public <O> @NotNull dev.siroshun.jfun.result.Result<O,EncodeError> encode(@NotNull @NotNull Out<O> out, @UnknownNullability Map<K, V> input) Description copied from interface:Encoder- Specified by:
encodein interfaceEncoder<K>- Type Parameters:
O- the type of the output destination- Parameters:
out- theOutfor writing the encoded datainput- the input data to encode- Returns:
- a result containing the encoded data, or a
EncodeErrorif the operation failed
-