Package org.hyperonline.hyperlib.pref
Class IntPreference
- java.lang.Object
-
- org.hyperonline.hyperlib.pref.Preference
-
- org.hyperonline.hyperlib.pref.IntPreference
-
public class IntPreference extends Preference
A class which represents an integer-valued preference
-
-
Constructor Summary
Constructors Constructor Description IntPreference(java.lang.String name, int value)
Create aIntPreference
object tracking the preference with the given name and default value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
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
-
IntPreference
public IntPreference(java.lang.String name, int value)
Create aIntPreference
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 int 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.getInt(String, int)
-
-