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(@NotNull String path,
T defaultValue)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
@NotNull PropertyValue<T> |
determineValue(@NotNull 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(@NotNull PropertyReader reader,
@NotNull ConvertErrorRecorder errorRecorder)
Constructs the value of the property from the property reader.
|
@NotNull String |
getPath() |
boolean |
isValidValue(T value)
Returns whether the value can be associated to the given property, i.e.
|
@NotNull String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisValidInResource, toExportValue@NotNull public @NotNull String getPath()
@NotNull public T getDefaultValue()
PropertygetDefaultValue in interface Property<T>@NotNull public @NotNull PropertyValue<T> determineValue(@NotNull @NotNull PropertyReader reader)
PropertyProperty.isValidValue(Object).determineValue in interface Property<T>reader - the reader to construct the value from (if possible)public boolean isValidValue(@Nullable
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 in Property.determineValue(ch.jalu.configme.resource.PropertyReader),
or in an extension of MigrationService.
isValidValue in interface Property<T>value - the value to check@Nullable protected abstract T getFromReader(@NotNull @NotNull PropertyReader reader, @NotNull @NotNull ConvertErrorRecorder errorRecorder)
reader - the reader to read fromerrorRecorder - error recorder to register errors even if a valid value is returnedCopyright © 2016–2023 The AuthMe Team. All rights reserved.