T
- property typepublic class CachingProperty<T> extends AbstractProperty<T> implements AbstractProperty.ValueChangeListener<T>
AbstractProperty
.
The current preference value is cached. The value is invalidated if the preference was changed.AbstractProperty.InvalidPreferenceValueException, AbstractProperty.ValueChangeEvent<T>, AbstractProperty.ValueChangeListener<T>
Modifier and Type | Field and Description |
---|---|
private T |
cache |
private boolean |
cacheActive |
private AbstractProperty<T> |
toCache |
defaultValue, key, preferences
Constructor and Description |
---|
CachingProperty(AbstractProperty<T> toCache)
Create a new caching property.
|
Modifier and Type | Method and 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.
|
addListener, addListenerImpl, addWeakListener, addWeakListenerImpl, equals, getDefaultValue, getKey, getPreferences, hashCode, isSet, remove, removeListener, removeListenerImpl, storeDefaultValue
private boolean cacheActive
private final AbstractProperty<T> toCache
CachingProperty(AbstractProperty<T> toCache)
toCache
- The property to cache.public T get()
AbstractProperty
get
in class AbstractProperty<T>
public boolean put(T value)
AbstractProperty
put
in class AbstractProperty<T>
value
- The new value of this propertypublic void valueChanged(AbstractProperty.ValueChangeEvent<? extends T> e)
AbstractProperty.ValueChangeListener
valueChanged
in interface AbstractProperty.ValueChangeListener<T>
e
- property change event