java.lang.Object
net.luis.utils.io.codec.ConfiguredCodec<C,O>
- Type Parameters:
C
- The type of the componentO
- The type of the object
A codec that is configured to encode and decode a specific component of an object.
This codec uses another codec to encode and decode the component.
The underlying codec is expected to be an instance of
This codec uses another codec to encode and decode the component.
The underlying codec is expected to be an instance of
NamedCodec
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecodeStart
(@NotNull TypeProvider<R> provider, R value) Decodes the component of the object using the given type provider and value.
This method will simply pass through the value to the underlying codec.<R> @NotNull Result
<R> encodeStart
(@NotNull TypeProvider<R> provider, R current, O object) Encodes the component of the object using the given type provider and current value.boolean
int
hashCode()
toString()
-
Field Details
-
codec
The codec used to encode and decode the component. -
getter
The function used to retrieve the component from the object.
-
-
Constructor Details
-
ConfiguredCodec
Constructs a new configured codec using the given codec and getter for the component.- Parameters:
codec
- The codecgetter
- The getter- Throws:
NullPointerException
- If the codec or getter is null
-
-
Method Details
-
encodeStart
@NotNull public <R> @NotNull Result<R> encodeStart(@NotNull @NotNull TypeProvider<R> provider, @NotNull R current, @Nullable O object) Encodes the component of the object using the given type provider and current value.- Type Parameters:
R
- The type of the current value- Parameters:
provider
- The type providercurrent
- The current valueobject
- The object- Returns:
- The result of the encoding operation
- Throws:
NullPointerException
- If the type provider or current value is null
-
decodeStart
@NotNull public <R> @NotNull Result<C> decodeStart(@NotNull @NotNull TypeProvider<R> provider, @Nullable R value) Decodes the component of the object using the given type provider and value.
This method will simply pass through the value to the underlying codec.- Type Parameters:
R
- The type of the value- Parameters:
provider
- The type providervalue
- The value- Returns:
- The result of the decoding operation
- Throws:
NullPointerException
- If the type provider is null
-
equals
-
hashCode
public int hashCode() -
toString
-