Class EnumPreferenceType<E extends Enum<E>>
java.lang.Object
dev.mintychochip.mint.preferences.types.EnumPreferenceType<E>
- Type Parameters:
E- the enum type
- All Implemented Interfaces:
PreferenceType<E>
@Experimental
@AvailableSince("1.3")
public final class EnumPreferenceType<E extends Enum<E>>
extends Object
implements PreferenceType<E>
A preference type for enum values.
Serializes enum values as their constant names and provides support for selection dialogs in the UI.
- Since:
- 1.3
-
Constructor Summary
ConstructorsConstructorDescriptionEnumPreferenceType(Class<E> enumClass) Creates a new enum preference type for the specified enum class. -
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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.mintychochip.mint.preferences.PreferenceType
typeKey
-
Constructor Details
-
EnumPreferenceType
Creates a new enum preference type for the specified enum class.- Parameters:
enumClass- the enum class, must not be null and must be an enum type- Throws:
IllegalArgumentException- if enumClass is null or not an enum
-
-
Method Details
-
deserialize
Description copied from interface:PreferenceTypeDeserializes a byte array into an object.- Specified by:
deserializein interfacePreferenceType<E extends Enum<E>>- Parameters:
object- the byte array to deserialize- Returns:
- the deserialized value
-
serialize
Description copied from interface:PreferenceTypeSerializes an object into a byte array.- Specified by:
serializein interfacePreferenceType<E extends Enum<E>>- Parameters:
object- the object to serialize- Returns:
- the serialized byte array
-
preferenceClass
Description copied from interface:PreferenceTypeGets the class this preference type handles.- Specified by:
preferenceClassin interfacePreferenceType<E extends Enum<E>>- Returns:
- the preference class
-