Interface PreferenceType<T>

Type Parameters:
T - the type this serializer handles
All Known Implementing Classes:
EnumPreferenceType

@Experimental @AvailableSince("1.3") public interface PreferenceType<T>
Defines how to serialize and deserialize preference values.

Implementations must handle conversion between byte arrays and objects.

Since:
1.3
  • Method Summary

    Modifier and Type
    Method
    Description
    deserialize(byte[] object)
    Deserializes a byte array into an object.
    Gets the class this preference type handles.
    byte[]
    serialize(T object)
    Serializes an object into a byte array.
    default TypeKey<T>
    Gets the type key for this preference type, including generic type information.
  • Method Details

    • deserialize

      @AvailableSince("1.3") T deserialize(byte[] object)
      Deserializes a byte array into an object.
      Parameters:
      object - the byte array to deserialize
      Returns:
      the deserialized value
    • serialize

      @AvailableSince("1.3") byte[] serialize(T object)
      Serializes an object into a byte array.
      Parameters:
      object - the object to serialize
      Returns:
      the serialized byte array
    • preferenceClass

      @AvailableSince("1.3") Class<T> preferenceClass()
      Gets the class this preference type handles.
      Returns:
      the preference class
    • typeKey

      @AvailableSince("1.3.6") default TypeKey<T> typeKey()
      Gets the type key for this preference type, including generic type information.

      For simple types, this defaults to TypeKey.of(preferenceClass()). For generic types like List<String>, implementations should override this to provide the full generic type information.

      Returns:
      the type key