T
- The type of object accessed by this propertypublic abstract class AbstractProperty<T> extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
AbstractProperty.InvalidPreferenceValueException
An exception that is thrown if a preference value is invalid.
|
private class |
AbstractProperty.PreferenceChangedListenerAdapter |
static class |
AbstractProperty.ValueChangeEvent<T>
An event that is triggered if the value of a property changes.
|
static interface |
AbstractProperty.ValueChangeListener<T>
A listener that listens to changes in the properties value.
|
private class |
AbstractProperty.WeakPreferenceAdapter
This class wraps the ValueChangeListener in a ListenableWeakReference that automatically removes itself
if the listener is garbage collected.
|
Modifier and Type | Field and Description |
---|---|
protected T |
defaultValue |
protected java.lang.String |
key |
protected IPreferences |
preferences
The preferences object this property is for.
|
Constructor and Description |
---|
AbstractProperty(java.lang.String key,
T defaultValue)
Constructs a new
AbstractProperty . |
Modifier and Type | Method and Description |
---|---|
void |
addListener(AbstractProperty.ValueChangeListener<? super T> listener)
Adds a listener that listens only for changes to this preference key.
|
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.
|
CachingProperty<T> |
cached()
Creates a new
CachingProperty instance for this property. |
boolean |
equals(java.lang.Object obj) |
abstract T |
get()
Replies the value of this property.
|
T |
getDefaultValue()
Replies the default value of this property.
|
java.lang.String |
getKey()
Replies the property key.
|
protected IPreferences |
getPreferences()
Gets the preferences used for this property.
|
int |
hashCode() |
boolean |
isSet()
Determines if this property is currently set in JOSM preferences.
|
abstract 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).
|
void |
removeListener(AbstractProperty.ValueChangeListener<? super T> listener)
Removes a listener that listens only for changes to this preference key.
|
protected void |
removeListenerImpl(PreferenceChangedListener adapter) |
protected void |
storeDefaultValue()
Store the default value to the preferences.
|
protected final IPreferences preferences
protected final java.lang.String key
protected final T defaultValue
public AbstractProperty(java.lang.String key, T defaultValue)
AbstractProperty
.key
- The property keydefaultValue
- The default valueprotected void storeDefaultValue()
public java.lang.String getKey()
public boolean isSet()
getPreferences()
contains this property.public T getDefaultValue()
public void remove()
public abstract T get()
public abstract boolean put(T value)
value
- The new value of this propertyprotected IPreferences getPreferences()
public CachingProperty<T> cached()
CachingProperty
instance for this property.public void addListener(AbstractProperty.ValueChangeListener<? super T> listener)
listener
- The listener to add.protected void addListenerImpl(PreferenceChangedListener adapter)
public void addWeakListener(AbstractProperty.ValueChangeListener<? super T> listener)
listener
- The listener to add.public void removeListener(AbstractProperty.ValueChangeListener<? super T> listener)
listener
- The listener to add.protected void removeListenerImpl(PreferenceChangedListener adapter)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object