Interface FieldTypeSerializer<T>
- Type Parameters:
T
- type for which this serializer is being registered.
- All Known Implementing Classes:
AdvancedEnumSerializer
public interface FieldTypeSerializer<T>
Interface representing a custom serializer and deserializer of a field type. You should write a
custom one if you are not happy with how AnnotationConfig serializes and deserializes by default.
You will also need to register your newly created class, implementing this interface, through
SerializerRegistry.registerSerializer(Class, FieldTypeSerializer)
- Since:
- 2.0.0
- Author:
- MrIvanPlays
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(DataObject data, SerializationContext<T> context, AnnotationAccessor annotations) AnnotationConfig invokes this call-back method during deserialization when it encounters a field of the specified type.static <T> FieldTypeSerializer<T>
functional
(TriFunction<DataObject, SerializationContext<T>, AnnotationAccessor, T> deserialize, TriFunction<T, SerializationContext<T>, AnnotationAccessor, DataObject> serialize) Creates a newFieldTypeSerializer
from 2TriFunctions
serialize
(T value, SerializationContext<T> context, AnnotationAccessor annotations) AnnotationConfig invokes this call-back method during serialization when it encounters a field of the specified type.
-
Method Details
-
functional
static <T> FieldTypeSerializer<T> functional(TriFunction<DataObject, SerializationContext<T>, AnnotationAccessor, T> deserialize, TriFunction<T, SerializationContext<T>, AnnotationAccessor, DataObject> serialize) Creates a newFieldTypeSerializer
from 2TriFunctions
- Type Parameters:
T
- type for which this serializer is being registered.- Parameters:
deserialize
- deserialize method (seedeserialize(DataObject, SerializationContext, AnnotationAccessor)
)serialize
- serialize method (seeserialize(Object, SerializationContext, AnnotationAccessor)
)- Returns:
- new field type serializer
-
deserialize
AnnotationConfig invokes this call-back method during deserialization when it encounters a field of the specified type.- Parameters:
data
- the data we received from the configcontext
- serialization contextannotations
- a way to access annotations of the object bound to the deserialized data- Returns:
- the generic value, the implementation of this interface has specified
- See Also:
-
deserializeAsFunction
default TriFunction<DataObject,SerializationContext<T>, deserializeAsFunction()AnnotationAccessor, T> - Returns:
- tri function of the deserialize method
-
serialize
AnnotationConfig invokes this call-back method during serialization when it encounters a field of the specified type.- Parameters:
value
- the data we need serializedcontext
- serialization contextannotations
- a way to access annotations of the object bound to the serialized data- Returns:
- a serialized object which is useful for dumping into a configuration file
- See Also:
-
serializeAsFunction
- Returns:
- tri function of the serialize method
-