Interface Serializer<T>

Type Parameters:
T - the type this serializer handles

public interface Serializer<T>
Interface for custom configuration value serialization.

Serializers convert configuration values between their object representation and string format for storage. Custom serializers are used for complex types that cannot be automatically serialized by the configuration system.

To use a custom serializer, annotate the configuration type with ConfigSerializer:


 @ConfigSerializer(MyTypeSerializer.class)
 public class MyType {
     // Type definition
 }

 public class MyTypeSerializer implements Serializer<MyType> {
     @Override
     public String serialize(MyType value) {
         return value.toString(); // Custom serialization logic
     }

     @Override
     public MyType deserialize(String s) {
         return MyType.parse(s); // Custom deserialization logic
     }
 }
 

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Converts a string back to the original value type.
    serialize(T value)
    Converts a value to its string representation for storage.
  • Method Details

    • serialize

      String serialize(T value)
      Converts a value to its string representation for storage.
      Parameters:
      value - the value to serialize
      Returns:
      the string representation
    • deserialize

      T deserialize(String s)
      Converts a string back to the original value type.
      Parameters:
      s - the string to deserialize
      Returns:
      the deserialized value