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

public abstract class AbstractProperty<T> extends Object
Captures the common functionality of preference properties
  • Field Details

  • Constructor Details

    • AbstractProperty

      protected AbstractProperty(String key, T defaultValue)
      Constructs a new AbstractProperty.
      Parameters:
      key - The property key
      defaultValue - The default value
      Since:
      5464
  • Method Details

    • storeDefaultValue

      protected void storeDefaultValue()
      Store the default value to the preferences.
    • getKey

      public String getKey()
      Replies the property key.
      Returns:
      The property key
    • isSet

      public boolean isSet()
      Determines if this property is currently set in JOSM preferences.
      Returns:
      true if getPreferences() contains this property.
    • getDefaultValue

      public T getDefaultValue()
      Replies the default value of this property.
      Returns:
      The default value of this property
    • remove

      public void remove()
      Removes this property from JOSM preferences (i.e replace it by its default value).
    • get

      public abstract T get()
      Replies the value of this property.
      Returns:
      the value of this property
      Since:
      5464
    • put

      public abstract boolean put(T value)
      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 new CachingProperty instance for this property.
      Returns:
      The new caching property instance.
      Since:
      12983
    • addListener

      public void addListener(AbstractProperty.ValueChangeListener<? super T> listener)
      Adds a listener that listens only for changes to this preference key.
      Parameters:
      listener - The listener to add.
      Since:
      10824
    • addListenerImpl

      protected void addListenerImpl(PreferenceChangedListener adapter)
    • addWeakListener

      public void addWeakListener(AbstractProperty.ValueChangeListener<? super T> listener)
      Adds a weak listener that listens only for changes to this preference key.
      Parameters:
      listener - The listener to add.
      Since:
      10824
    • removeListener

      public void removeListener(AbstractProperty.ValueChangeListener<? super T> listener)
      Removes a listener that listens only for changes to this preference key.
      Parameters:
      listener - The listener to add.
      Since:
      10824
    • removeListenerImpl

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object