Interface TypeSerializer<T>

Type Parameters:
T - the type this serializer handles
All Known Implementing Classes:
DurationSerializer, PrimitiveSerializers.BooleanSerializer, PrimitiveSerializers.ByteSerializer, PrimitiveSerializers.CharacterSerializer, PrimitiveSerializers.DoubleSerializer, PrimitiveSerializers.FloatSerializer, PrimitiveSerializers.IntegerSerializer, PrimitiveSerializers.LongSerializer, PrimitiveSerializers.ShortSerializer, PrimitiveSerializers.StringSerializer, UUIDSerializer

public interface TypeSerializer<T>
Handles conversion between configuration nodes and Java types.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canHandle(@NotNull Class<?> type)
    Checks if this serializer can handle the given type.
    deserialize(@NotNull ConfigNode node, @NotNull Class<T> type)
    Deserializes a configuration node to the target type.
    void
    serialize(T value, @NotNull MutableConfigNode node)
    Serializes a value to a configuration node.
  • Method Details

    • deserialize

      T deserialize(@NotNull @NotNull ConfigNode node, @NotNull @NotNull Class<T> type) throws SerializationException
      Deserializes a configuration node to the target type.
      Parameters:
      node - the source node
      type - the target type class
      Returns:
      the deserialized value
      Throws:
      SerializationException - if deserialization fails
    • serialize

      void serialize(@NotNull T value, @NotNull @NotNull MutableConfigNode node) throws SerializationException
      Serializes a value to a configuration node.
      Parameters:
      value - the value to serialize
      node - the target node
      Throws:
      SerializationException - if serialization fails
    • canHandle

      default boolean canHandle(@NotNull @NotNull Class<?> type)
      Checks if this serializer can handle the given type.

      Used for dynamic serializer selection when the exact type is not registered but a compatible serializer exists.

      Parameters:
      type - the type to check
      Returns:
      true if this serializer can handle the type