Package org.hyperonline.hyperlib.pref
Class DoublePreference
- java.lang.Object
-
- org.hyperonline.hyperlib.pref.Preference
-
- org.hyperonline.hyperlib.pref.DoublePreference
-
public class DoublePreference extends Preference
A class which represents a double-valued preference
-
-
Constructor Summary
Constructors Constructor Description DoublePreference(java.lang.String name, double value)Create aDoublePreferenceobject tracking the preference with the given name and default value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleget()Get the current value of the preferences file entry, or the default if no entry exists.protected booleanhasChanged()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 voidputDefaultValue()Put an entry with the default value.-
Methods inherited from class org.hyperonline.hyperlib.pref.Preference
getName, putDefaultIfEmpty
-
-
-
-
Constructor Detail
-
DoublePreference
public DoublePreference(java.lang.String name, double value)Create aDoublePreferenceobject 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:
hasChangedin classPreference- Returns:
- true if the value has changed, false otherwise
-
putDefaultValue
protected void putDefaultValue()
Put an entry with the default value.- Specified by:
putDefaultValuein classPreference
-
get
public double 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.getDouble(String, double)
-
-