Interface Setting<T>

Type Parameters:
T - the data type for the value
All Known Implementing Classes:
AbstractSetting, ListListSetting, ListSetting, MapListSetting, StringSetting

public interface Setting<T>
Interface for a preference value. Implementations must provide a proper equals method.
Since:
12881 (moved from package org.openstreetmap.josm.data.preferences)
  • Method Summary

    Modifier and Type
    Method
    Description
    Clone the current object.
    default boolean
    equalVal(T otherVal)
    Check if the value of this Setting object is equal to the given value.
    Returns a setting whose value is null.
    Get the time for this setting.
    Returns the value of this setting.
    boolean
    Return if the setting has been marked as new.
    void
    setNew(boolean isNew)
    Mark setting as new.
    void
    setTime(Long time)
    Set the time for this setting.
    void
    Enable usage of the visitor pattern.
  • Method Details

    • getValue

      Returns the value of this setting.
      Returns:
      the value of this setting
    • equalVal

      default boolean equalVal(T otherVal)
      Check if the value of this Setting object is equal to the given value.
      Parameters:
      otherVal - the other value
      Returns:
      true if the values are equal
    • copy

      Clone the current object.
      Returns:
      an identical copy of the current object
    • visit

      void visit(SettingVisitor visitor)
      Enable usage of the visitor pattern.
      Parameters:
      visitor - the visitor
    • getNullInstance

      Returns a setting whose value is null. Cannot be static, because there is no static inheritance.
      Returns:
      a Setting object that isn't null itself, but returns null for getValue()
    • setTime

      void setTime(Long time)
      Set the time for this setting. For default preferences. They are saved in a cache file. Keeping the time allows to discard very old default settings.
      Parameters:
      time - the time in seconds since epoch
    • getTime

      Get the time for this setting.
      Returns:
      the time for this setting
      See Also:
    • setNew

      void setNew(boolean isNew)
      Mark setting as new. For default preferences. A setting is marked as new, if it has been seen in the current session. Methods like IPreferences.get(java.lang.String, java.lang.String), can be called from different parts of the code with the same key. In this case, the supplied default value must match. However, this is only an error if the mismatching default value has been seen in the same session (and not loaded from cache).
      Parameters:
      isNew - true, if it is new
    • isNew

      boolean isNew()
      Return if the setting has been marked as new.
      Returns:
      true, if the setting has been marked as new
      See Also: