Class AbstractProperty<T>
java.lang.Object
org.openstreetmap.josm.data.preferences.AbstractProperty<T>
- Type Parameters:
T- The type of object accessed by this property
- Direct Known Subclasses:
AbstractToStringProperty,CachedProperty,CachingProperty,FallbackProperty,ListProperty
Captures the common functionality of preference properties
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn exception that is thrown if a preference value is invalid.private final classstatic classAn event that is triggered if the value of a property changes.static interfaceA listener that listens to changes in the properties value.private classThis class wraps the ValueChangeListener in a ListenableWeakReference that automatically removes itself if the listener is garbage collected. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Tprotected final Stringprotected final IPreferencesThe preferences object this property is for. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractProperty(String key, T defaultValue) Constructs a newAbstractProperty. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(AbstractProperty.ValueChangeListener<? super T> listener) Adds a listener that listens only for changes to this preference key.protected voidaddListenerImpl(PreferenceChangedListener adapter) voidaddWeakListener(AbstractProperty.ValueChangeListener<? super T> listener) Adds a weak listener that listens only for changes to this preference key.cached()Creates a newCachingPropertyinstance for this property.booleanabstract Tget()Replies the value of this property.Replies the default value of this property.getKey()Replies the property key.protected IPreferencesGets the preferences used for this property.inthashCode()booleanisSet()Determines if this property is currently set in JOSM preferences.abstract booleanSets this property to the specified value.voidremove()Removes this property from JOSM preferences (i.e replace it by its default value).voidremoveListener(AbstractProperty.ValueChangeListener<? super T> listener) Removes a listener that listens only for changes to this preference key.protected voidprotected voidStore the default value to the preferences.
-
Field Details
-
preferences
The preferences object this property is for. -
key
-
defaultValue
-
-
Constructor Details
-
AbstractProperty
Constructs a newAbstractProperty.- Parameters:
key- The property keydefaultValue- The default value- Since:
- 5464
-
-
Method Details
-
storeDefaultValue
Store the default value to the preferences. -
getKey
Replies the property key.- Returns:
- The property key
-
isSet
Determines if this property is currently set in JOSM preferences.- Returns:
- true if
getPreferences()contains this property.
-
getDefaultValue
Replies the default value of this property.- Returns:
- The default value of this property
-
remove
Removes this property from JOSM preferences (i.e replace it by its default value). -
get
Replies the value of this property.- Returns:
- the value of this property
- Since:
- 5464
-
put
Sets this property to the specified value.- Parameters:
value- The new value of this property- Returns:
- true if something has changed (i.e. value is different than before)
- Since:
- 5464
-
getPreferences
Gets the preferences used for this property.- Returns:
- The preferences for this property.
- Since:
- 12999
-
cached
Creates a newCachingPropertyinstance for this property.- Returns:
- The new caching property instance.
- Since:
- 12983
-
addListener
Adds a listener that listens only for changes to this preference key.- Parameters:
listener- The listener to add.- Since:
- 10824
-
addListenerImpl
-
addWeakListener
Adds a weak listener that listens only for changes to this preference key.- Parameters:
listener- The listener to add.- Since:
- 10824
-
removeListener
Removes a listener that listens only for changes to this preference key.- Parameters:
listener- The listener to add.- Since:
- 10824
-
removeListenerImpl
-
hashCode
-
equals
-