T - the property typepublic abstract class BaseProperty<T> extends Object implements Property<T>
Property. All properties should extend from this class.
This base implementation makes interacting with properties null safe by guaranteeing that the default value
and its determined value can never be null.
| Constructor and Description |
|---|
BaseProperty(String path,
T defaultValue)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
T |
determineValue(PropertyReader reader)
Returns the value, based on the given reader, which should be used for this property.
|
T |
getDefaultValue()
Returns the default value of this property.
|
protected abstract T |
getFromReader(PropertyReader reader)
Constructs the value of the property from the property reader.
|
String |
getPath() |
boolean |
isPresent(PropertyReader reader)
Returns true if a valid value for this property is present in the property reader, i.e.
|
boolean |
isValidValue(T value)
Returns whether the value can be associated to the given property, i.e.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waittoExportValuepublic String getPath()
public T getDefaultValue()
PropertygetDefaultValue in interface Property<T>public T determineValue(PropertyReader reader)
PropertyBaseProperty never return null. The return value must be in sync with
Property.isValidValue(Object).determineValue in interface Property<T>reader - the reader to construct the value from (if possible)public boolean isPresent(PropertyReader reader)
Propertypublic boolean isValidValue(T value)
Property
This method is used in ConfigurationDataImpl.setValue(ch.jalu.configme.properties.Property<T>, T), which
throws an exception if this method returns false. Therefore, this method is intended as a last catch
for invalid values and to ensure that programmatically no invalid value can be set. Extended validation of
values encountered in the property reader should be preferably handled Property.determineValue(ch.jalu.configme.resource.PropertyReader) or
in a MigrationService.
isValidValue in interface Property<T>value - the value to check@Nullable protected abstract T getFromReader(PropertyReader reader)
reader - the reader to read fromCopyright © 2016–2018 The AuthMe Team. All rights reserved.