Class CachedProperty<T>
- java.lang.Object
-
- org.openstreetmap.josm.data.preferences.AbstractProperty<T>
-
- org.openstreetmap.josm.data.preferences.CachedProperty<T>
-
- Type Parameters:
T
- The value type of this property
- All Implemented Interfaces:
PreferenceChangedListener
public abstract class CachedProperty<T> extends AbstractProperty<T> implements PreferenceChangedListener
This is an old-style cached preference value. You can replace this using theAbstractProperty.cached()
,AbstractProperty.cached()
accessors
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
AbstractProperty.InvalidPreferenceValueException, AbstractProperty.ValueChangeEvent<T>, AbstractProperty.ValueChangeListener<T>
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
defaultValueAsString
private int
updateCount
private T
value
-
Fields inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
defaultValue, key, preferences
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CachedProperty(java.lang.String key, java.lang.String defaultValueAsString)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
fromString(java.lang.String s)
T
get()
Replies the value of this property.java.lang.String
getAsString()
T
getDefaultValue()
Replies the default value of this property.java.lang.String
getDefaultValueAsString()
int
getUpdateCount()
void
preferenceChanged(PreferenceChangeEvent e)
Triggered when a preference entry value changes.void
put(java.lang.String value)
boolean
put(T value)
Sets this property to the specified value.protected void
updateValue()
-
Methods inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
addListener, addListenerImpl, addWeakListener, cached, equals, getKey, getPreferences, hashCode, isSet, remove, removeListener, removeListenerImpl, storeDefaultValue
-
-
-
-
Field Detail
-
defaultValueAsString
private final java.lang.String defaultValueAsString
-
updateCount
private int updateCount
-
-
Constructor Detail
-
CachedProperty
protected CachedProperty(java.lang.String key, java.lang.String defaultValueAsString)
-
-
Method Detail
-
updateValue
protected final void updateValue()
-
fromString
protected abstract T fromString(java.lang.String s)
-
get
public T get()
Description copied from class:AbstractProperty
Replies the value of this property.- Specified by:
get
in classAbstractProperty<T>
- Returns:
- the value of this property
-
put
public void put(java.lang.String value)
-
put
public final boolean put(T value)
Description copied from class:AbstractProperty
Sets this property to the specified value.- Specified by:
put
in classAbstractProperty<T>
- Parameters:
value
- The new value of this property- Returns:
- true if something has changed (i.e. value is different than before)
-
getUpdateCount
public int getUpdateCount()
-
getDefaultValue
public T getDefaultValue()
Description copied from class:AbstractProperty
Replies the default value of this property.- Overrides:
getDefaultValue
in classAbstractProperty<T>
- Returns:
- The default value of this property
-
getDefaultValueAsString
public java.lang.String getDefaultValueAsString()
-
getAsString
public java.lang.String getAsString()
-
preferenceChanged
public void preferenceChanged(PreferenceChangeEvent e)
Description copied from interface:PreferenceChangedListener
Triggered when a preference entry value changes.- Specified by:
preferenceChanged
in interfacePreferenceChangedListener
- Parameters:
e
- the preference change event
-
-