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.boolean
hasSerializer
(Class<?> serializedType) Returns whether the specified type has a serializer registered.<T> void
registerSerializer
(Class<T> serializedType, FieldTypeSerializer<T> typeSerializer) Registers a new serializer.<T> void
registerSerializer
(Class<T> serializedType, BiFunction<DataObject, Field, T> deSerialize, BiFunction<T, Field, DataObject> serialize) Registers a new serializer.void
unregisterSerializer
(Class<?> 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 serialized of the serializedType- Throws:
IllegalArgumentException
- if a serializer for this type has been already registered
-
registerSerializer
public <T> void registerSerializer(Class<T> serializedType, BiFunction<DataObject, Field, T> deSerialize, BiFunction<T, Field, DataObject> serialize) Registers a new serializer.- Type Parameters:
T
- generic- Parameters:
serializedType
- the field type that should be serializeddeSerialize
- the deserialize methodserialize
- the serialize method
-
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
-
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
-