Package org.hyperonline.hyperlib.pref
Class BooleanPreference
- java.lang.Object
-
- org.hyperonline.hyperlib.pref.Preference
-
- org.hyperonline.hyperlib.pref.BooleanPreference
-
public class BooleanPreference extends Preference
A class which represents a boolean-valued preference
-
-
Constructor Summary
Constructors Constructor Description BooleanPreference(java.lang.String name, boolean value)
Create aBooleanPreference
object tracking the preference with the given name and default value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
get()
Get the current value of the preferences file entry, or the default if no entry exists.protected boolean
hasChanged()
Check if the value has changed since last being checked, or if this is the first time this method was called and the value has changed from the default.protected void
putDefaultValue()
Put an entry with the default value.-
Methods inherited from class org.hyperonline.hyperlib.pref.Preference
getName, putDefaultIfEmpty
-
-
-
-
Constructor Detail
-
BooleanPreference
public BooleanPreference(java.lang.String name, boolean value)
Create aBooleanPreference
object tracking the preference with the given name and default value. Calling this function does not yet modify the preferences file.- Parameters:
name
- The string id of the preferencevalue
- The default value
-
-
Method Detail
-
hasChanged
protected boolean hasChanged()
Check if the value has changed since last being checked, or if this is the first time this method was called and the value has changed from the default.- Specified by:
hasChanged
in classPreference
- Returns:
- true if the value has changed, false otherwise
-
putDefaultValue
protected void putDefaultValue()
Put an entry with the default value.- Specified by:
putDefaultValue
in classPreference
-
get
public boolean get()
Get the current value of the preferences file entry, or the default if no entry exists.- Returns:
- The value of the preference
- See Also:
Preferences.getBoolean(String, boolean)
-
-