public class TimeUnitPropertyType extends EnumPropertyType<TimeUnit> implements Range<TimeUnit>
java.util.concurrent.TimeUnit. | Constructor Example | Comments | ||
|---|---|---|---|
Property<TimeUnit> A_PROPERTY = new Property<TimeUnit>("name", new TimeUnitPropertyType()); |
No default value. | ||
Property<TimeUnit> A_PROPERTY = new Property<TimeUnit>("name", new TimeUnitPropertyType(TimeUnit.SECONDS)); |
With default value "TimeUnit.SECONDS". | ||
| Type of value(s) | Examples | Result | Comments |
| Valid | NANOSECONDS | TimeUnit.NANOSECONDS | Validate successfully. |
| Valid | HouRs | TimeUnit.HOURS | Validate successfully. |
| Invalid | cow | null |
Validate will throw an exception. The resulting value is null. |
| Invalid | «empty string» | null |
|
| Invalid | «empty string after trim» | null |
|
| Invalid | null |
defaultValue OR null |
Validate will throw an exception. Return default value if set, otherwise null. |
TimeUnit,
Serialized FormTYPE| Constructor and Description |
|---|
TimeUnitPropertyType()
Constructor where the defaultValue, minValue and maxValue is
null. |
TimeUnitPropertyType(TimeUnit defaultValue)
Constructor where minValue and maxValue is
null. |
TimeUnitPropertyType(TimeUnit minValue,
TimeUnit maxValue)
Constructor where the defaultValue is
null. |
TimeUnitPropertyType(TimeUnit defaultValue,
TimeUnit minValue,
TimeUnit maxValue)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
TimeUnit |
getMaxValue()
The maximum value (inclusive)
|
TimeUnit |
getMinValue()
The minimum value (inclusive)
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
boolean |
isUseMaxValue()
If there is a maximum limit.
|
boolean |
isUseMinValue()
If there is a minimum limit.
|
void |
setMaxValue(TimeUnit maxValue)
Sets the maximum limit (inclusive).
|
void |
setMinValue(TimeUnit minValue)
Sets the minimum limit (inclusive).
|
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
void |
validateIsInRange(String propertyName,
TimeUnit value)
Validates that a value is inside the valid range of min and max value if defined.
|
void |
validateMinMaxValues(String propertyName)
Validates that minValue is less or equal to maxValue, must be called by validateConstraints, and if there is a default value that is inside the valid range.
|
TimeUnit |
validateValue(String propertyName,
String value)
Converts the string representation of to a typed value.
|
getEnumClazz, getEnumConstants, isAllLowercased, isAllUppercased, setEnumClazzequals, getDefaultValue, getDefaultValueAsString, getDefaultValueDescription, getDescription, getDescription, getInitializationPriority, getIo, getLogger, getTypeName, hasDefaultValue, isDefaultValueValid, postGetValueProcessing, setDefaultValue, setInitializationPriority, setIo, setTypedValue, setTypeName, toString, toType, validate, validateNullTypepublic TimeUnitPropertyType()
null.public TimeUnitPropertyType(TimeUnit defaultValue)
null.defaultValue - default value returned if property value is undefined.public TimeUnitPropertyType(TimeUnit defaultValue, TimeUnit minValue, TimeUnit maxValue)
defaultValue - the default TimeUnit value.minValue - the minimum TimeUnit value (inclusive), if null than no minimum limit.maxValue - the maximum TimeUnit value (inclusive), if null than no maximum limit.public TimeUnitPropertyType(TimeUnit minValue, TimeUnit maxValue)
null.minValue - the minimum TimeUnit value (inclusive), if null than no minimum limit.maxValue - the maximum TimeUnit value (inclusive), if null than no maximum limit.public void validateConstraints(String propertyName) throws PropertyException
PropertyTypevalidateConstraints in class EnumPropertyType<TimeUnit>propertyName - the name of the property used for logging purposes, to
identify the unique property which PropertyType has constraint
issues.PropertyException - if the constraints have invalid/conflicting values.Property.validate()public TimeUnit validateValue(String propertyName, String value) throws PropertyException
PropertyTypevalidateValue in class EnumPropertyType<TimeUnit>propertyName - the name of the property used for logging purposes. To uniquely identify the Property with validation issues.value - the string representation of the propertyPropertyException - if the conversion failed.public TimeUnit getMinValue()
RangegetMinValue in interface Range<TimeUnit>null than no minimum limit.public TimeUnit getMaxValue()
RangegetMaxValue in interface Range<TimeUnit>null than no minimum limit.public boolean isUseMinValue()
RangeisUseMinValue in interface Range<TimeUnit>true if getMinValue() differs from null, otherwise false.public boolean isUseMaxValue()
RangeisUseMaxValue in interface Range<TimeUnit>true if getMaxValue() differs from null, otherwise false.public void setMinValue(TimeUnit minValue)
RangesetMinValue in interface Range<TimeUnit>minValue - the minimum limit, if null than no limit.public void setMaxValue(TimeUnit maxValue)
RangesetMaxValue in interface Range<TimeUnit>maxValue - the maximum limit, if null than no limit.public void validateIsInRange(String propertyName, TimeUnit value) throws PropertyException
RangevalidateIsInRange in interface Range<TimeUnit>propertyName - the propertyvalue - the valuePropertyException - if minValue is not null and value is less than, or maxValue is not null and value is greather than.PropertyType.validateValue(String, String)public void validateMinMaxValues(String propertyName) throws PropertyException
RangevalidateMinMaxValues in interface Range<TimeUnit>propertyName - the name of the property.PropertyException - if minValue is greather than maxValue.PropertyType.validateConstraints(String)public List<String> getRestrictions()
PropertyTypegetRestrictions in class EnumPropertyType<TimeUnit>