Class FallbackProperty<T>
- java.lang.Object
-
- org.openstreetmap.josm.data.preferences.AbstractProperty<T>
-
- org.openstreetmap.josm.data.preferences.FallbackProperty<T>
-
- Type Parameters:
T
- The content type
public class FallbackProperty<T> extends AbstractProperty<T>
Property that wraps another property along with a fallback property that is used as default value.- Since:
- 12987
-
-
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 AbstractProperty<T>
fallback
private AbstractProperty<T>
property
-
Fields inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
defaultValue, key, preferences
-
-
Constructor Summary
Constructors Constructor Description FallbackProperty(AbstractProperty<T> property, AbstractProperty<T> fallback)
Constructs a newFallbackProperty
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
addListener, cached, equals, getKey, getPreferences, hashCode, removeListener
-
-
-
-
Field Detail
-
property
private final AbstractProperty<T> property
-
fallback
private final AbstractProperty<T> fallback
-
-
Constructor Detail
-
FallbackProperty
public FallbackProperty(AbstractProperty<T> property, AbstractProperty<T> fallback)
Constructs a newFallbackProperty
.- Parameters:
property
- the wrapped propertyfallback
- fallback property that takes effect in theget()
method whenproperty
is not set
-
-
Method Detail
-
getDelegateProperty
public AbstractProperty<T> getDelegateProperty()
Get the wrapped property.- Returns:
- the wrapped property
-
getFallbackProperty
public AbstractProperty<T> getFallbackProperty()
Get the fallback property.- Returns:
- the fallback property
-
storeDefaultValue
protected void storeDefaultValue()
Description copied from class:AbstractProperty
Store the default value to the preferences.- Overrides:
storeDefaultValue
in classAbstractProperty<T>
-
isSet
public boolean isSet()
Description copied from class:AbstractProperty
Determines if this property is currently set in JOSM preferences.- Overrides:
isSet
in classAbstractProperty<T>
- Returns:
- true if
getPreferences()
contains this property.
-
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
-
remove
public void remove()
Description copied from class:AbstractProperty
Removes this property from JOSM preferences (i.e replace it by its default value).- Overrides:
remove
in classAbstractProperty<T>
-
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)
-
addListenerImpl
protected void addListenerImpl(PreferenceChangedListener adapter)
- Overrides:
addListenerImpl
in classAbstractProperty<T>
-
addWeakListener
public void addWeakListener(AbstractProperty.ValueChangeListener<? super T> listener)
Description copied from class:AbstractProperty
Adds a weak listener that listens only for changes to this preference key.- Overrides:
addWeakListener
in classAbstractProperty<T>
- Parameters:
listener
- The listener to add.
-
removeListenerImpl
protected void removeListenerImpl(PreferenceChangedListener adapter)
- Overrides:
removeListenerImpl
in classAbstractProperty<T>
-
-