- Type Parameters:
T- The type of the optional value.E- The type of the optional elements.
public interface OptionalValueCodec<T,E>
A codec for optional values.
-
Method Summary
Modifier and TypeMethodDescriptiondecodeOptional(Optional<ESExpr> expr, ESExprCodec.FailurePath path) Decode an optional expression into an optional value.encodeOptional(T value) Encode an optional value into an optional expression.booleanisEncodedEqual(T x, T y) Determines if two optional values, after being encoded, are equal.static <T> OptionalValueCodec<Optional<T>, T> optionalValueCodec(ESExprCodec<T> itemCodec) Creates anOptionalValueCodecinstance for handling optional values.
-
Method Details
-
isEncodedEqual
-
encodeOptional
-
decodeOptional
Decode an optional expression into an optional value.- Parameters:
expr- The optional expression.path- The path of the current value within the decoded object for diagnostic purposes.- Returns:
- The optional value.
- Throws:
DecodeException- when the value cannot be decoded.
-
optionalValueCodec
Creates anOptionalValueCodecinstance for handling optional values.- Type Parameters:
T- The type of the values contained within the optional value.- Parameters:
itemCodec- The codec used to encode and decode the underlying value.- Returns:
- A new
OptionalValueCodecinstance configured with the provided item codec.
-