org.openstreetmap.josm.data.preferences
Class CachedProperty<T>

java.lang.Object
  extended by org.openstreetmap.josm.data.preferences.AbstractProperty<T>
      extended by org.openstreetmap.josm.data.preferences.CachedProperty<T>
All Implemented Interfaces:
Preferences.PreferenceChangedListener
Direct Known Subclasses:
Marker.TemplateEntryProperty

public abstract class CachedProperty<T>
extends AbstractProperty<T>
implements Preferences.PreferenceChangedListener


Field Summary
private  java.lang.String defaultValueAsString
           
private  int updateCount
           
private  T value
           
 
Fields inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
defaultValue, key
 
Constructor Summary
protected CachedProperty(java.lang.String key, java.lang.String defaultValueAsString)
           
 
Method Summary
protected abstract  T fromString(java.lang.String s)
           
 T get()
          Replies the value of this property.
 java.lang.String getAsString()
           
 T getDefaultValue()
          Replies the default value of this property.
 java.lang.String getDefaultValueAsString()
           
 int getUpdateCount()
           
 void preferenceChanged(Preferences.PreferenceChangeEvent e)
           
 void put(java.lang.String value)
           
 boolean put(T value)
          Sets this property to the specified value.
protected  void updateValue()
           
 
Methods inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
getKey, isSet, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultValueAsString

private final java.lang.String defaultValueAsString

value

private T value

updateCount

private int updateCount
Constructor Detail

CachedProperty

protected CachedProperty(java.lang.String key,
                         java.lang.String defaultValueAsString)
Method Detail

updateValue

protected void updateValue()

fromString

protected abstract T fromString(java.lang.String s)

get

public T get()
Description copied from class: AbstractProperty
Replies the value of this property.

Specified by:
get in class AbstractProperty<T>
Returns:
the value of this property

put

public void put(java.lang.String value)

put

public final boolean put(T value)
Description copied from class: AbstractProperty
Sets this property to the specified value.

Specified by:
put in class AbstractProperty<T>
Parameters:
value - The new value of this property
Returns:
true if something has changed (i.e. value is different than before)

getUpdateCount

public int getUpdateCount()

getDefaultValue

public T getDefaultValue()
Description copied from class: AbstractProperty
Replies the default value of this property.

Overrides:
getDefaultValue in class AbstractProperty<T>
Returns:
The default value of this property

getDefaultValueAsString

public java.lang.String getDefaultValueAsString()

getAsString

public java.lang.String getAsString()

preferenceChanged

public void preferenceChanged(Preferences.PreferenceChangeEvent e)
Specified by:
preferenceChanged in interface Preferences.PreferenceChangedListener


JOSM