Class CachingProperty<T>
- java.lang.Object
-
- org.openstreetmap.josm.data.preferences.AbstractProperty<T>
-
- org.openstreetmap.josm.data.preferences.CachingProperty<T>
-
- Type Parameters:
T
- property type
- All Implemented Interfaces:
AbstractProperty.ValueChangeListener<T>
public class CachingProperty<T> extends AbstractProperty<T> implements AbstractProperty.ValueChangeListener<T>
This is a special wrapper ofAbstractProperty
. The current preference value is cached. The value is invalidated if the preference was changed.- Since:
- 10824
-
-
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 T
cache
private boolean
cacheValid
private AbstractProperty<T>
toCache
-
Fields inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
defaultValue, key, preferences
-
-
Constructor Summary
Constructors Constructor Description CachingProperty(AbstractProperty<T> toCache)
Create a new caching property.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
get()
Replies the value of this property.boolean
put(T value)
Sets this property to the specified value.void
valueChanged(AbstractProperty.ValueChangeEvent<? extends T> e)
Method called when a property value has changed.-
Methods inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
addListener, addListenerImpl, addWeakListener, cached, equals, getDefaultValue, getKey, getPreferences, hashCode, isSet, remove, removeListener, removeListenerImpl, storeDefaultValue
-
-
-
-
Field Detail
-
cacheValid
private boolean cacheValid
-
toCache
private final AbstractProperty<T> toCache
-
-
Constructor Detail
-
CachingProperty
CachingProperty(AbstractProperty<T> toCache)
Create a new caching property.- Parameters:
toCache
- The property to cache.
-
-
Method Detail
-
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 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)
-
valueChanged
public void valueChanged(AbstractProperty.ValueChangeEvent<? extends T> e)
Description copied from interface:AbstractProperty.ValueChangeListener
Method called when a property value has changed.- Specified by:
valueChanged
in interfaceAbstractProperty.ValueChangeListener<T>
- Parameters:
e
- property change event
-
-