public abstract static class Property.BaseProperty<T> extends java.lang.Object implements Property<T>
Property.BaseProperty<T>, Property.BooleanProperty, Property.CharsetProperty, Property.DurationInSecondsProperty, Property.DurationProperty, Property.EnumProperty<T extends java.lang.Enum<T>>, Property.IntegerProperty, Property.LongProperty, Property.ObjectProperty, Property.StringProperty, Property.Validating<T>
Modifier and Type | Field and Description |
---|---|
private java.util.Optional<T> |
defaultValue |
private java.lang.String |
name |
private java.lang.Class<T> |
type |
BY_NAME_COMPARATOR, NAME_EXTRACTOR
Modifier | Constructor and Description |
---|---|
protected |
BaseProperty(java.lang.String name,
java.lang.Class<T> type) |
protected |
BaseProperty(java.lang.String name,
java.lang.Class<T> type,
T defaultValue) |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
fromStorage(java.lang.Object value) |
java.util.Optional<T> |
get(PropertyResolver resolver) |
java.util.Optional<T> |
getDefault() |
java.lang.String |
getName() |
T |
getOrCustomDefault(PropertyResolver resolver,
T defaultValue) |
java.lang.Class<T> |
getType() |
void |
set(PropertyResolver resolver,
T value) |
protected java.lang.Object |
toStorage(T value) |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
bool, bool, charset, charset, duration, duration, duration, durationSec, durationSec, durationSec, enum_, enum_, getOrNull, getRequired, getRequiredDefault, integer, integer, long_, long_, object, object, remove, string, string, validating
findByName, findFirstMatchByName, getNameList, getNames, ofName, removeByName, safeCompareByName
private final java.lang.String name
private final java.lang.Class<T> type
private final java.util.Optional<T> defaultValue
protected BaseProperty(java.lang.String name, java.lang.Class<T> type)
public java.lang.String getName()
getName
in interface NamedResource
public java.lang.Class<T> getType()
public java.util.Optional<T> getDefault()
getDefault
in interface Property<T>
Optional
pre-defined default valuepublic java.util.Optional<T> get(PropertyResolver resolver)
get
in interface Property<T>
resolver
- The PropertyResolver
to query for the property value.Optional
result - if resolver contains a value then the resolver's value, otherwise
the pre-defined default
public T getOrCustomDefault(PropertyResolver resolver, T defaultValue)
getOrCustomDefault
in interface Property<T>
resolver
- The PropertyResolver
to query for the property value.defaultValue
- The default value to return if no specific value found in resolverpublic void set(PropertyResolver resolver, T value)
set
in interface Property<T>
resolver
- The PropertyResolver
to update with the property value.value
- The value to setprotected java.lang.Object toStorage(T value)
protected abstract T fromStorage(java.lang.Object value)
public java.lang.String toString()
toString
in class java.lang.Object