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
  • Enum Constant Details

  • Method Details

    • values

      public static SerializerRegistry[] 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

      public static SerializerRegistry valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • registerSerializer

      public <T> void registerSerializer(Class<T> serializedType, FieldTypeSerializer<T> typeSerializer)
      Registers a new serializer.
      Type Parameters:
      T - generic
      Parameters:
      serializedType - the field type that should be serialized
      typeSerializer - 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 serialized
      deSerialize - the deserialize method
      serialize - the serialize method
    • unregisterSerializer

      public void unregisterSerializer(Class<?> serializedType)
      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

      public boolean hasSerializer(Class<?> serializedType)
      Returns whether the specified type has a serializer registered.
      Parameters:
      serializedType - the serialized type you want to check
      Returns:
      a boolean value
    • getSerializer

      public Optional<FieldTypeSerializer<?>> getSerializer(Class<?> serializedType)
      Returns an Optional value, which may or may not be filled with a FieldTypeSerializer, depending on if the serializedType 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