T - The preference type.public abstract class Preference<T>
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
protected |
Preference(java.util.prefs.Preferences preferences,
java.lang.String key)
Construct
Preference. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.lang.String |
fromValue(T value)
Convert the preference value to it's string representation.
|
T |
get()
Get the preference value.
|
T |
get(T defaultValue)
Get the preference value.
|
java.lang.String |
key()
Get the preference key.
|
java.util.prefs.Preferences |
preferences()
Get the
Preferences object storing this preference. |
void |
put(T value)
Set the preference value.
|
void |
remove()
Remove the preference value.
|
java.lang.String |
toString() |
protected abstract T |
toValue(java.lang.String valueString)
Convert the preference's string representation to it's value.
|
protected Preference(java.util.prefs.Preferences preferences,
java.lang.String key)
Preference.preferences - The Preferences object storing this preference.key - The preference key.public java.util.prefs.Preferences preferences()
Preferences object storing this preference.Preferences object storing this preference.public java.lang.String key()
@Nullable public T get()
null if the preference is undefined.public T get(T defaultValue)
defaultValue - The default preference value to return in case the preference is undefined.public void put(@Nullable T value)
value - The value to set. If null the preference is removed.public void remove()
@Nullable protected abstract T toValue(java.lang.String valueString)
valueString - The string to convert.protected abstract java.lang.String fromValue(T value)
value - The value to convert.public java.lang.String toString()
toString in class java.lang.Object