Class AbstractToStringProperty<T>
- java.lang.Object
-
- org.openstreetmap.josm.data.preferences.AbstractProperty<T>
-
- org.openstreetmap.josm.data.preferences.AbstractToStringProperty<T>
-
- Type Parameters:
T
- The property content type.
- Direct Known Subclasses:
AbstractToStringProperty.ChildProperty
,BooleanProperty
,DoubleProperty
,IntegerProperty
,LongProperty
,NamedColorProperty
,ParallelWayAction.KeyboardModifiersProperty
,StringProperty
,StrokeProperty
public abstract class AbstractToStringProperty<T> extends AbstractProperty<T>
This class represents a property that can be represented as String.- Since:
- 10824
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractToStringProperty.ChildProperty<T>
This is a version of this property that attempts to get the property with a more specialized key and - if that fails - uses the property value as default.-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
AbstractProperty.InvalidPreferenceValueException, AbstractProperty.ValueChangeEvent<T>, AbstractProperty.ValueChangeListener<T>
-
-
Field Summary
-
Fields inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
defaultValue, key, preferences
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractToStringProperty(java.lang.String key, T defaultValue)
Create a new property and store the default value.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
fromString(java.lang.String string)
Converts the string to an object of the given type.T
get()
Replies the value of this property.protected java.lang.String
getAsString()
Gets the preference value as String.protected AbstractToStringProperty<T>
getChildProperty(java.lang.String key)
Gets a setting that defaults to this setting if the key is not set.AbstractToStringProperty<T>
getSpecialized(java.lang.String spec)
Gets a specialized setting value that has the current value as defaultboolean
put(T value)
Sets this property to the specified value.protected abstract java.lang.String
toString(T t)
Converts the string to an object of the given type.-
Methods inherited from class org.openstreetmap.josm.data.preferences.AbstractProperty
addListener, addListenerImpl, addWeakListener, cached, equals, getDefaultValue, getKey, getPreferences, hashCode, isSet, remove, removeListener, removeListenerImpl, storeDefaultValue
-
-
-
-
Constructor Detail
-
AbstractToStringProperty
protected AbstractToStringProperty(java.lang.String key, T defaultValue)
Create a new property and store the default value.- Parameters:
key
- The keydefaultValue
- The default value.- See Also:
AbstractProperty(String, Object)
-
-
Method Detail
-
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
-
fromString
protected abstract T fromString(java.lang.String string)
Converts the string to an object of the given type.- Parameters:
string
- The string- Returns:
- The object.
- Throws:
AbstractProperty.InvalidPreferenceValueException
- If the value could not be converted.
-
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)
-
toString
protected abstract java.lang.String toString(T t)
Converts the string to an object of the given type.- Parameters:
t
- The object.- Returns:
- The string representing the object
- Throws:
AbstractProperty.InvalidPreferenceValueException
- If the value could not be converted.
-
getAsString
protected java.lang.String getAsString()
Gets the preference value as String.- Returns:
- The string preference value.
-
getSpecialized
public AbstractToStringProperty<T> getSpecialized(java.lang.String spec)
Gets a specialized setting value that has the current value as defaultThe key will be getKey().spec
- Parameters:
spec
- The key specialization- Returns:
- The property
-
getChildProperty
protected AbstractToStringProperty<T> getChildProperty(java.lang.String key)
Gets a setting that defaults to this setting if the key is not set.- Parameters:
key
- The more specialized key.- Returns:
- The new setting.
-
-