T - the property typepublic interface Property<T>
Property implementations should always extend from BaseProperty instead of implementing
this interface directly.
| Modifier and Type | Method and Description |
|---|---|
PropertyValue<T> |
determineValue(PropertyReader propertyReader)
Returns the value, based on the given reader, which should be used for this property.
|
T |
getDefaultValue()
Returns the default value of this property.
|
String |
getPath() |
default boolean |
isValidInResource(PropertyReader propertyReader)
Convenience method to check whether the property is present in the given reader and a valid representation
of the property type.
|
boolean |
isValidValue(T value)
Returns whether the value can be associated to the given property, i.e.
|
Object |
toExportValue(T value)
Converts the given value to a representation that is suitable for exporting by a property resource.
|
String getPath()
PropertyValue<T> determineValue(PropertyReader propertyReader)
BaseProperty never return null. The return value must be in sync with
isValidValue(Object).propertyReader - the reader to construct the value from (if possible)default boolean isValidInResource(PropertyReader propertyReader)
determineValue(PropertyReader) if you need the value afterwards to avoid performing the same
operation twice.propertyReader - the reader to check the value inT getDefaultValue()
boolean isValidValue(T value)
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 determineValue(ch.jalu.configme.resource.PropertyReader),
or in an extension of MigrationService.
value - the value to check@Nullable Object toExportValue(T value)
The values which are suitable for returning depend on the support of the used property resource. By default,
the supported types include null, String, Integer, Double, Boolean; Collection of the aforementioned
types; Map with String keys and values of any of the aforementioned types. Maps and collections can be nested at
any arbitrary level. Null signifies that the property/value should be skipped in the export.
value - the value to convert to an export valueCopyright © 2016–2021 The AuthMe Team. All rights reserved.