Class ScalarSerializer.Annotated<V>

java.lang.Object
org.spongepowered.configurate.serialize.ScalarSerializer<V>
org.spongepowered.configurate.serialize.ScalarSerializer.Annotated<V>
Type Parameters:
V - the value to deserialize
All Implemented Interfaces:
TypeSerializer<V>, TypeSerializer.Annotated<V>
Enclosing class:
ScalarSerializer<T>

public abstract static class ScalarSerializer.Annotated<V> extends ScalarSerializer<V>
A specialization of the scalar serializer that favors annotated type methods over unannotated methods.
Since:
4.2.0
  • Constructor Details

    • Annotated

      protected Annotated(Class<V> type)
      Create a new annotated scalar serializer that handles the provided type.

      type must not be a raw parameterized type.

      Parameters:
      type - type to handle
      Since:
      4.2.0
    • Annotated

      protected Annotated(io.leangen.geantyref.TypeToken<V> type)
      Create a new annotated scalar serializer that handles the provided type.
      Parameters:
      type - type to handle
      Since:
      4.2.0
  • Method Details

    • deserialize

      public abstract V deserialize(AnnotatedType type, Object obj) throws SerializationException
      Description copied from class: ScalarSerializer
      Given an object of unknown type, attempt to convert it into the given type.
      Overrides:
      deserialize in class ScalarSerializer<V>
      Parameters:
      type - the specific type of the type's usage
      obj - the object to convert
      Returns:
      a converted object
      Throws:
      SerializationException - if the object could not be converted for any reason
    • deserialize

      public V deserialize(Type type, Object obj) throws SerializationException
      Description copied from class: ScalarSerializer
      Given an object of unknown type, attempt to convert it into the given type.
      Specified by:
      deserialize in class ScalarSerializer<V>
      Parameters:
      type - the specific type of the type's usage
      obj - the object to convert
      Returns:
      a converted object
      Throws:
      SerializationException - if the object could not be converted for any reason
    • serialize

      protected abstract Object serialize(AnnotatedType type, V item, Predicate<Class<?>> typeSupported)
      Description copied from class: ScalarSerializer
      Serialize the provided value to a supported type, testing against the provided predicate.

      Annotated type information is provided for reference.

      Overrides:
      serialize in class ScalarSerializer<V>
      Parameters:
      type - the annotated type of the field being serialized
      item - the value to serialize
      typeSupported - a predicate to allow choosing which types are supported
      Returns:
      a serialized form of this object
    • serialize

      protected Object serialize(V item, Predicate<Class<?>> typeSupported)
      Description copied from class: ScalarSerializer
      Serialize the provided value to a supported type, testing against the provided predicate.
      Specified by:
      serialize in class ScalarSerializer<V>
      Parameters:
      item - the value to serialize
      typeSupported - a predicate to allow choosing which types are supported
      Returns:
      a serialized form of this object