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 TypeMethodDescriptiondeserialize(byte[] object) Deserializes a byte array into an object.Gets the class this preference type handles.byte[]Serializes an object into a byte array.typeKey()Gets the type key for this preference type, including generic type information.
-
Method Details
-
deserialize
Deserializes a byte array into an object.- Parameters:
object- the byte array to deserialize- Returns:
- the deserialized value
-
serialize
Serializes an object into a byte array.- Parameters:
object- the object to serialize- Returns:
- the serialized byte array
-
preferenceClass
Gets the class this preference type handles.- Returns:
- the preference class
-
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 likeList<String>, implementations should override this to provide the full generic type information.- Returns:
- the type key
-