public class OptionalConverter extends Object implements QiSerializer.Converter
Optional
objects.
This class is responsible for adapting Optional
objects of a custom
value type from and to Optional
objects of a type that the native
layer can handle.
QiSerializer
,
QiSerializer.Converter
,
Optional
Constructor and Description |
---|
OptionalConverter() |
Modifier and Type | Method and Description |
---|---|
boolean |
canDeserialize(Object object,
Type targetType) |
boolean |
canSerialize(Object object) |
Optional<?> |
deserialize(QiSerializer serializer,
Object object,
Type targetType)
Creates an object of optional type
targetType adapted from an
optional object object . |
Optional<?> |
serialize(QiSerializer serializer,
Object object)
Creates an optional object adapted from an optional object
object . |
public boolean canSerialize(Object object)
canSerialize
in interface QiSerializer.Converter
object
is an instance of Optional
.public Optional<?> serialize(QiSerializer serializer, Object object) throws QiConversionException
object
. The logic is:
QiSerializer.serialize(Object)
on it.Optional
.serialize
in interface QiSerializer.Converter
QiConversionException
- !canSerialize(object)
, then the
cause of the exception is an IllegalArgumentException
.canSerialize(Object)
,
Optional
,
Optional.map(Function)
public boolean canDeserialize(Object object, Type targetType)
canDeserialize
in interface QiSerializer.Converter
object
is an instance of Optional
and
targetType
is a specialization of Optional
.public Optional<?> deserialize(QiSerializer serializer, Object object, Type targetType) throws QiConversionException
targetType
adapted from an
optional object object
. The logic is:
QiSerializer.deserialize(Object, Type)
on it
with the optional value type as the target type.Optional
.deserialize
in interface QiSerializer.Converter
QiConversionException
- !canDeserialize(object)
, then the cause of the
exception is a IllegalArgumentException
.canDeserialize(Object, Type)
,
Optional
,
Optional.map(Function)
Copyright © 2020. All rights reserved.