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 properequals
method.- Since:
- 12881 (moved from package
org.openstreetmap.josm.data.preferences
)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Setting<T>
copy()
Clone the current object.default boolean
equalVal(T otherVal)
Check if the value of this Setting object is equal to the given value.Setting<T>
getNullInstance()
Returns a setting whose value is null.java.lang.Long
getTime()
Get the time for this setting.T
getValue()
Returns the value of this setting.boolean
isNew()
Return if the setting has been marked as new.void
setNew(boolean isNew)
Mark setting as new.void
setTime(java.lang.Long time)
Set the time for this setting.void
visit(SettingVisitor visitor)
Enable usage of the visitor pattern.
-
-
-
Method Detail
-
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
-
visit
void visit(SettingVisitor visitor)
Enable usage of the visitor pattern.- Parameters:
visitor
- the visitor
-
getNullInstance
Setting<T> 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(java.lang.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
java.lang.Long getTime()
Get the time for this setting.- Returns:
- the time for this setting
- See Also:
setTime(java.lang.Long)
-
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 likeIPreferences.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:
setNew(boolean)
-
-