- Type Parameters:
C
- The type the decoder is for
- All Known Subinterfaces:
Codec<C>
,KeyableCodec<C>
,KeyableDecoder<C>
- All Known Implementing Classes:
EitherCodec
,ListCodec
,MapCodec
,NamedCodec
,OptionalCodec
,RangeCodec
,UnitCodec
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a decoder for a specific type.
The implementation decodes a value of the type specified by the type provider
and returns a result containing the decoded value or an error message.
The implementation decodes a value of the type specified by the type provider
and returns a result containing the decoded value or an error message.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R> C
decode
(@NotNull TypeProvider<R> provider, R value) Decodes the value of the specified type and returns the decoded value directly.decodeStart
(@NotNull TypeProvider<R> provider, R value) Decodes the value of the specified type and returns the result.
The result contains the decoded value or an error message.default <O> @NotNull Decoder
<O> mapDecoder
(@NotNull ResultMappingFunction<C, O> from) Maps the type of the decoded value to another type.
The mapping function is applied to the decoded result of the decoding process.
The mapping function returns a result containing the mapped value or an error message if the mapping process fails.
-
Method Details
-
decode
Decodes the value of the specified type and returns the decoded value directly.- Type Parameters:
R
- The type to decode from- Parameters:
provider
- The type providervalue
- The value to decode- Returns:
- The decoded value
- Throws:
NullPointerException
- If the type provider is nullDecoderException
- If an error occurs during decoding- See Also:
-
decodeStart
@NotNull <R> @NotNull Result<C> decodeStart(@NotNull @NotNull TypeProvider<R> provider, @Nullable R value) Decodes the value of the specified type and returns the result.
The result contains the decoded value or an error message.- Type Parameters:
R
- The type to decode from- Parameters:
provider
- The type providervalue
- The value to decode- Returns:
- The result
- Throws:
NullPointerException
- If the type provider is null
-
mapDecoder
@NotNull default <O> @NotNull Decoder<O> mapDecoder(@NotNull @NotNull ResultMappingFunction<C, O> from) Maps the type of the decoded value to another type.
The mapping function is applied to the decoded result of the decoding process.
The mapping function returns a result containing the mapped value or an error message if the mapping process fails.- Type Parameters:
O
- The type to map to- Parameters:
from
- The mapping function- Returns:
- The mapped decoder
- Throws:
NullPointerException
- If the mapping function is null
-