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>fallbackprivate 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 voidaddListenerImpl(PreferenceChangedListener adapter)voidaddWeakListener(AbstractProperty.ValueChangeListener<? super T> listener)Adds a weak listener that listens only for changes to this preference key.Tget()Replies the value of this property.TgetDefaultValue()Replies the default value of this property.AbstractProperty<T>getDelegateProperty()Get the wrapped property.AbstractProperty<T>getFallbackProperty()Get the fallback property.booleanisSet()Determines if this property is currently set in JOSM preferences.booleanput(T value)Sets this property to the specified value.voidremove()Removes this property from JOSM preferences (i.e replace it by its default value).protected voidremoveListenerImpl(PreferenceChangedListener adapter)protected voidstoreDefaultValue()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 whenpropertyis 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:AbstractPropertyStore the default value to the preferences.- Overrides:
storeDefaultValuein classAbstractProperty<T>
-
isSet
public boolean isSet()
Description copied from class:AbstractPropertyDetermines if this property is currently set in JOSM preferences.- Overrides:
isSetin classAbstractProperty<T>- Returns:
- true if
getPreferences()contains this property.
-
getDefaultValue
public T getDefaultValue()
Description copied from class:AbstractPropertyReplies the default value of this property.- Overrides:
getDefaultValuein classAbstractProperty<T>- Returns:
- The default value of this property
-
remove
public void remove()
Description copied from class:AbstractPropertyRemoves this property from JOSM preferences (i.e replace it by its default value).- Overrides:
removein classAbstractProperty<T>
-
get
public T get()
Description copied from class:AbstractPropertyReplies the value of this property.- Specified by:
getin classAbstractProperty<T>- Returns:
- the value of this property
-
put
public boolean put(T value)
Description copied from class:AbstractPropertySets this property to the specified value.- Specified by:
putin 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:
addListenerImplin classAbstractProperty<T>
-
addWeakListener
public void addWeakListener(AbstractProperty.ValueChangeListener<? super T> listener)
Description copied from class:AbstractPropertyAdds a weak listener that listens only for changes to this preference key.- Overrides:
addWeakListenerin classAbstractProperty<T>- Parameters:
listener- The listener to add.
-
removeListenerImpl
protected void removeListenerImpl(PreferenceChangedListener adapter)
- Overrides:
removeListenerImplin classAbstractProperty<T>
-
-