Interface TypeSerializer<T>
- Type Parameters:
- T- the type
- All Known Subinterfaces:
- TypeSerializer.Annotated<V>
- All Known Implementing Classes:
- AbstractListChildSerializer,- ScalarSerializer,- ScalarSerializer.Annotated
public interface TypeSerializer<T>
Represents an object which can serialize and deserialize objects of a
 given type.
 
The type serializer interface has methods both for working with
 annotated types, and discarding annotated type information. If annotation
 information is desired, the TypeSerializer.Annotated interface overrides the
 standard TypeSerializer interface to prefer annotated type information.
- Since:
- 4.0.0
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA type serializer that prefers type use annotation metadata to deserialize the type.
- 
Method SummaryModifier and TypeMethodDescriptiondefault Tdeserialize(AnnotatedType type, ConfigurationNode node) Deserialize an object (of the correct type) from the given configuration node.deserialize(Type type, ConfigurationNode node) Deserialize an object (of the correct type) from the given configuration node.default @Nullable TemptyValue(AnnotatedType specificType, ConfigurationOptions options) Create an empty value of the appropriate type.default @Nullable TemptyValue(Type specificType, ConfigurationOptions options) Create an empty value of the appropriate type.static <T> ScalarSerializer<T>of(Class<T> type, BiFunction<T, Predicate<Class<?>>, Object> serializer, CheckedFunction<Object, T, SerializationException> deserializer) Given the provided functions, create a new serializer for a scalar value.static <T> ScalarSerializer<T>of(Type type, BiFunction<T, Predicate<Class<?>>, Object> serializer, CheckedFunction<Object, T, SerializationException> deserializer) Given the provided functions, create a new serializer for a scalar value.default voidserialize(AnnotatedType type, @Nullable T obj, ConfigurationNode node) Serialize an object to the given configuration node.voidserialize(Type type, @Nullable T obj, ConfigurationNode node) Serialize an object to the given configuration node.
- 
Method Details- 
ofstatic <T> ScalarSerializer<T> of(Type type, BiFunction<T, Predicate<Class<?>>, Object> serializer, CheckedFunction<Object, T, SerializationException> deserializer) Given the provided functions, create a new serializer for a scalar value.The returned serializer must fulfill all the requirements of a ScalarSerializer- Type Parameters:
- T- the type of value to deserialize
- Parameters:
- type- the type of value returned by the serializer
- serializer- the serialization function, implementing- ScalarSerializer.serialize(Object, Predicate)
- deserializer- the deserialization function, implementing- ScalarSerializer.deserialize(Type, Object)
- Returns:
- a new and unregistered type serializer
- Since:
- 4.0.0
 
- 
ofstatic <T> ScalarSerializer<T> of(Class<T> type, BiFunction<T, Predicate<Class<?>>, Object> serializer, CheckedFunction<Object, T, SerializationException> deserializer) Given the provided functions, create a new serializer for a scalar value.The returned serializer must fulfill all the requirements of a ScalarSerializer- Type Parameters:
- T- the type of value to deserialize
- Parameters:
- type- the type of value. Must not be a parameterized type
- serializer- the serialization function, implementing- ScalarSerializer.serialize(Object, Predicate)
- deserializer- the deserialization function, implementing- ScalarSerializer.deserialize(Type, Object)
- Returns:
- a new and unregistered type serializer
- Since:
- 4.0.0
- See Also:
 
- 
deserializeDeserialize an object (of the correct type) from the given configuration node.- Parameters:
- type- the annotated type of return value required
- node- the node containing serialized data
- Returns:
- an object
- Throws:
- SerializationException- if the presented data is invalid
- Since:
- 4.2.0
 
- 
deserializeDeserialize an object (of the correct type) from the given configuration node.- Parameters:
- type- the type of return value required
- node- the node containing serialized data
- Returns:
- an object
- Throws:
- SerializationException- if the presented data is invalid
- Since:
- 4.0.0
 
- 
serializedefault void serialize(AnnotatedType type, @Nullable T obj, ConfigurationNode node) throws SerializationException Serialize an object to the given configuration node.- Parameters:
- type- the annotated type of the input object
- obj- the object to be serialized
- node- the node to write to
- Throws:
- SerializationException- if the object cannot be serialized
- Since:
- 4.2.0
 
- 
serializeSerialize an object to the given configuration node.- Parameters:
- type- the type of the input object
- obj- the object to be serialized
- node- the node to write to
- Throws:
- SerializationException- if the object cannot be serialized
- Since:
- 4.0.0
 
- 
emptyValueCreate an empty value of the appropriate type.This method is for the most part designed to create empty collection types, though it may be useful for scalars in limited cases. - Parameters:
- specificType- specific subtype to create an empty value of
- options- options used from the loading node
- Returns:
- new empty value
- Since:
- 4.0.0
 
- 
emptyValueCreate an empty value of the appropriate type.This method is for the most part designed to create empty collection types, though it may be useful for scalars in limited cases. - Parameters:
- specificType- specific annotated subtype to create an empty value of
- options- options used from the loading node
- Returns:
- new empty value
- Since:
- 4.2.0
 
 
-