T
- The content typepublic class FallbackProperty<T> extends AbstractProperty<T>
AbstractProperty.InvalidPreferenceValueException, AbstractProperty.ValueChangeEvent<T>, AbstractProperty.ValueChangeListener<T>
Modifier and Type | Field and Description |
---|---|
private AbstractProperty<T> |
fallback |
private AbstractProperty<T> |
property |
defaultValue, key, preferences
Constructor and Description |
---|
FallbackProperty(AbstractProperty<T> property,
AbstractProperty<T> fallback)
Constructs a new
FallbackProperty . |
Modifier and Type | Method and Description |
---|---|
protected void |
addListenerImpl(PreferenceChangedListener adapter) |
void |
addWeakListener(AbstractProperty.ValueChangeListener<? super T> listener)
Adds a weak listener that listens only for changes to this preference key.
|
T |
get()
Replies the value of this property.
|
T |
getDefaultValue()
Replies the default value of this property.
|
AbstractProperty<T> |
getDelegateProperty()
Get the wrapped property.
|
AbstractProperty<T> |
getFallbackProperty()
Get the fallback property.
|
boolean |
isSet()
Determines if this property is currently set in JOSM preferences.
|
boolean |
put(T value)
Sets this property to the specified value.
|
void |
remove()
Removes this property from JOSM preferences (i.e replace it by its default value).
|
protected void |
removeListenerImpl(PreferenceChangedListener adapter) |
protected void |
storeDefaultValue()
Store the default value to the preferences.
|
addListener, cached, equals, getKey, getPreferences, hashCode, removeListener
private final AbstractProperty<T> property
private final AbstractProperty<T> fallback
public FallbackProperty(AbstractProperty<T> property, AbstractProperty<T> fallback)
FallbackProperty
.property
- the wrapped propertyfallback
- fallback property that takes effect in the get()
method when
property
is not setpublic AbstractProperty<T> getDelegateProperty()
public AbstractProperty<T> getFallbackProperty()
protected void storeDefaultValue()
AbstractProperty
storeDefaultValue
in class AbstractProperty<T>
public boolean isSet()
AbstractProperty
isSet
in class AbstractProperty<T>
getPreferences()
contains this property.public T getDefaultValue()
AbstractProperty
getDefaultValue
in class AbstractProperty<T>
public void remove()
AbstractProperty
remove
in class AbstractProperty<T>
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 propertyprotected void addListenerImpl(PreferenceChangedListener adapter)
addListenerImpl
in class AbstractProperty<T>
public void addWeakListener(AbstractProperty.ValueChangeListener<? super T> listener)
AbstractProperty
addWeakListener
in class AbstractProperty<T>
listener
- The listener to add.protected void removeListenerImpl(PreferenceChangedListener adapter)
removeListenerImpl
in class AbstractProperty<T>