Enum SerializerRegistry
java.lang.Object
java.lang.Enum<SerializerRegistry>
com.mrivanplays.annotationconfig.core.serialization.SerializerRegistry
- All Implemented Interfaces:
Serializable
,Comparable<SerializerRegistry>
,java.lang.constant.Constable
Represents a registry of all the serializers.
- Since:
- 2.0.0
- Author:
- MrIvanPlays
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the default serializer.getSerializer
(Class<?> serializedType) Returns anOptional
value, which may or may not be filled with aFieldTypeSerializer
, depending on if theserializedType
has been registered or not.getSerializer
(Type serializedType) Returns anOptional
value, which may or may not be filled with aFieldTypeSerializer
, depending on if theserializedType
has been registered or not.boolean
hasSerializer
(Class<?> serializedType) Returns whether the specified type has a serializer registered.boolean
hasSerializer
(Type serializedType) Returns whether the specified type has a serializer registered.<T> void
registerSerializer
(Class<T> serializedType, FieldTypeSerializer<T> typeSerializer) Registers a new serializer.void
registerSerializer
(Type serializedType, FieldTypeSerializer<?> typeSerializer) Registers a new serializer.<T> void
registerSimpleSerializer
(Class<T> serializedType, Function<DataObject, T> deserialize, Function<T, DataObject> serialize) Register a newFieldTypeSerializer
which can resolve data without aSerializationContext
and aAnnotationAccessor
<T> void
registerSimpleValueDeserializer
(Class<T> serializedType, Function<DataObject, T> deserialize) Registers a newFieldTypeSerializer
with only a deserialize method which can resolve without aSerializationContext
and aAnnotationAccessor
.
How is the serialize method handled? If there is a registered serializer for thisserializedType
, then the method will forward serialize calls to it, otherwise serialize calls are forwarded to the default serializer.<T> void
registerSimpleValueSerializer
(Class<T> serializedType, Function<T, DataObject> serialize) Registers a newFieldTypeSerializer
with only a serialize method which can resolve without aSerializationContext
and aAnnotationAccessor
.
How is the deserialize method handled? If there is a registered serializer for thsserializedType
, then the method will forward deserialize calls to it, otherwise deserialize calls are forwarded to the default serializer.void
unregisterSerializer
(Class<?> serializedType) Unregisters the serializer of the specified serialized typevoid
unregisterSerializer
(Type serializedType) Unregisters the serializer of the specified serialized typestatic SerializerRegistry
Returns the enum constant of this type with the specified name.static SerializerRegistry[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
registerSerializer
Registers a new serializer.- Type Parameters:
T
- generic- Parameters:
serializedType
- the field type that should be serializedtypeSerializer
- the serializer of the serializedType- Throws:
IllegalArgumentException
- if a serializer for this type has been already registered
-
registerSerializer
Registers a new serializer.- Parameters:
serializedType
- the generic field type that should be serializedtypeSerializer
- the serializer of the serialized type- Throws:
IllegalArgumentException
- if a serializer for this type has been already registered.
-
registerSimpleSerializer
public <T> void registerSimpleSerializer(Class<T> serializedType, Function<DataObject, T> deserialize, Function<T, DataObject> serialize) Register a newFieldTypeSerializer
which can resolve data without aSerializationContext
and aAnnotationAccessor
- Type Parameters:
T
- generic- Parameters:
serializedType
- the field type that should be serializeddeserialize
- deserialization method of the serializedTypeserialize
- serialization method of the serializedType
-
registerSimpleValueSerializer
public <T> void registerSimpleValueSerializer(Class<T> serializedType, Function<T, DataObject> serialize) Registers a newFieldTypeSerializer
with only a serialize method which can resolve without aSerializationContext
and aAnnotationAccessor
.
How is the deserialize method handled? If there is a registered serializer for thsserializedType
, then the method will forward deserialize calls to it, otherwise deserialize calls are forwarded to the default serializer.- Type Parameters:
T
- generic- Parameters:
serializedType
- the field type that should be serializedserialize
- serialization method of the serializedType
-
registerSimpleValueDeserializer
public <T> void registerSimpleValueDeserializer(Class<T> serializedType, Function<DataObject, T> deserialize) Registers a newFieldTypeSerializer
with only a deserialize method which can resolve without aSerializationContext
and aAnnotationAccessor
.
How is the serialize method handled? If there is a registered serializer for thisserializedType
, then the method will forward serialize calls to it, otherwise serialize calls are forwarded to the default serializer.- Type Parameters:
T
- generic- Parameters:
serializedType
- the field type that should be deserializeddeserialize
- deserialization method of the serialized type
-
unregisterSerializer
Unregisters the serializer of the specified serialized type- Parameters:
serializedType
- the serialized type you want the serializer of unregistered- Throws:
IllegalArgumentException
- if there isn't a serializer for the type specified
-
unregisterSerializer
Unregisters the serializer of the specified serialized type- Parameters:
serializedType
- the serialized type you want the serializer of unregistered- Throws:
IllegalArgumentException
- if there isn't a serializer for the type specified
-
hasSerializer
Returns whether the specified type has a serializer registered.- Parameters:
serializedType
- the serialized type you want to check- Returns:
- a boolean value
-
hasSerializer
Returns whether the specified type has a serializer registered.- Parameters:
serializedType
- the serialized type you want to check- Returns:
- a boolean value
-
getSerializer
Returns anOptional
value, which may or may not be filled with aFieldTypeSerializer
, depending on if theserializedType
has been registered or not.- Parameters:
serializedType
- the type which is serialized you want the serializer of- Returns:
- an optional with value or an empty optional
-
getSerializer
Returns anOptional
value, which may or may not be filled with aFieldTypeSerializer
, depending on if theserializedType
has been registered or not.- Parameters:
serializedType
- the type which is serialized you want the serializer of- Returns:
- an optional with value or an empty optional
-
getDefaultSerializer
Returns the default serializer. This is used when there isn't a registered serializer available for a specific value.- Returns:
- default serializer
-