- Type Parameters:
C
- The type of the value to decode
- All Superinterfaces:
Decoder<C>
- All Known Subinterfaces:
KeyableCodec<C>
- All Known Implementing Classes:
RangeCodec
Extension of
A key is a string used to identify a value in a data structure.
Decoder
that allows decoding keys.A key is a string used to identify a value in a data structure.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondecodeKey
(@NotNull TypeProvider<R> provider, @NotNull String key) Decodes a key to a value of the specified type and returns the result.
The result contains the decoded key or an error message.static <C> @NotNull KeyableDecoder
<C> Creates a new keyable decoder from the specified decoder and key decoder.
The key decoder function converts a key to a value.
If the key decoder is not able to handle a key, it can simply return null.Methods inherited from interface net.luis.utils.io.codec.decoder.Decoder
decode, decodeStart, mapDecoder
-
Method Details
-
of
@NotNull static <C> @NotNull KeyableDecoder<C> of(@NotNull @NotNull Decoder<C> decoder, @NotNull @NotNull Function<String, @Nullable C> keyDecoder) Creates a new keyable decoder from the specified decoder and key decoder.
The key decoder function converts a key to a value.
If the key decoder is not able to handle a key, it can simply return null.- Type Parameters:
C
- The type of the value to decode- Parameters:
decoder
- The decoderkeyDecoder
- The key decoder function- Returns:
- The keyable decoder
- Throws:
NullPointerException
- If the decoder or the key decoder function is null
-
decodeKey
@NotNull <R> @NotNull Result<C> decodeKey(@NotNull @NotNull TypeProvider<R> provider, @NotNull @NotNull String key) Decodes a key to a value of the specified type and returns the result.
The result contains the decoded key or an error message.- Type Parameters:
R
- The type to decode from- Parameters:
provider
- The type providerkey
- The key to decode- Returns:
- The result
- Throws:
NullPointerException
- If the type provider or the key is null
-