public class BasicSettingsStorage extends Object implements SettingsStorage, Serializable
Constructor and Description |
---|
BasicSettingsStorage()
Initializes an empty storage.
|
Modifier and Type | Method and Description |
---|---|
void |
addSettingsListener(SettingsListener l)
Adds a new listener which gets notified if settings have changed.
|
<T> T |
getSetting(Key key)
Returns the setting with the specified key.
|
boolean |
hasSetting(Key key)
Returns
true if there is a setting for the specified key. |
boolean |
hasSettingDefault(Key key)
Returns
true if there is a default setting for the
specified key. |
protected void |
notifySettingChanged(Key key,
Object valueOld,
Object valueNew,
boolean defaultSetting)
Invokes the settingChanged method on all registered listeners.
|
<T> void |
removeSetting(Key key)
Removes the setting with the specified key.
|
<T> void |
removeSettingDefault(Key key)
Removes the default setting with the specified key.
|
void |
removeSettingsListener(SettingsListener l)
Removes the specified listener.
|
<T> void |
setSetting(Key key,
T value)
Sets the setting with the specified key to the specified value.
|
protected <T> void |
setSetting(Key key,
T value,
boolean isDefault)
Sets the setting or default setting with the specified key to a new
value.
|
<T> void |
setSettingDefault(Key key,
T value)
Sets a default value for the setting with the specified key.
|
public boolean hasSetting(Key key)
true
if there is a setting for the specified key.key
- Key of the setting.true
if the key has a setting,
false
otherwise.public <T> T getSetting(Key key)
getSetting
in interface SettingsStorage
T
- Type of setting.key
- Key.public <T> void setSetting(Key key, T value)
setSetting
in interface SettingsStorage
T
- Type of setting.key
- Key.value
- Value to be set.public <T> void removeSetting(Key key)
removeSetting
in interface SettingsStorage
T
- Type of setting.key
- Key.public boolean hasSettingDefault(Key key)
true
if there is a default setting for the
specified key.key
- Key of the setting.true
if the key has a default setting,
false
otherwise.public <T> void setSettingDefault(Key key, T value)
setSettingDefault
in interface SettingsStorage
T
- Type of setting.key
- Key.value
- Value to be set.public <T> void removeSettingDefault(Key key)
removeSettingDefault
in interface SettingsStorage
T
- value typekey
- key of the settingprotected <T> void setSetting(Key key, T value, boolean isDefault)
T
- Type of setting.key
- Key.value
- Value to be set.isDefault
- true
when the value should be the default,
otherwise false
public void addSettingsListener(SettingsListener l)
l
- listener to be addedpublic void removeSettingsListener(SettingsListener l)
l
- listener to be removedprotected void notifySettingChanged(Key key, Object valueOld, Object valueNew, boolean defaultSetting)
key
- Key.valueOld
- Old value.valueNew
- New value.defaultSetting
- true
if a default setting has changed,
false
otherwise.Copyright © 2009-2013. All Rights Reserved.