public class DoublePropertyType extends PropertyType<Double> implements Range<Double>
java.lang.Double. Double.parseDouble(string).
| Constructor Example | Comments | ||
|---|---|---|---|
| Property<Double> A_PROPERTY = new Property<Double>("name", new DoublePropertyType()); |
No default value, no minimum or maximum constraints. | ||
Property<Double> A_PROPERTY = |
Default value is "25.4", no minimum or maximum constraints. | ||
Property<Double> A_PROPERTY = |
No default value,minimum is "0" and maximum is "50", both inclusive.. | ||
Property<Double> A_PROPERTY = |
Default value is "25.0",minimum is "0" and maximum is "50", both inclusive. | ||
| Type of value(s) | Examples | Result | Comments |
| Valid | -25.4 | new Double(-25.4) | Validate successfully. |
| Valid | 34.5E12 | new Double(34.5E12) | 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. |
Double.parseDouble(String),
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static String |
TYPE
The type name string constant of DoublePropertyType.
|
| Constructor and Description |
|---|
DoublePropertyType()
Default constructor, no minimum, maximum or default value.
|
DoublePropertyType(double defaultValue)
Constructor with default value.
|
DoublePropertyType(Double defaultValue)
Constructor with default value.
|
DoublePropertyType(double minValue,
double maxValue)
Constructor with minimum and maximum value.
|
DoublePropertyType(Double minValue,
Double maxValue)
Constructor with minimum and maximum value.
|
DoublePropertyType(double defaultValue,
double minValue,
double maxValue)
Constructor with minimum, maximum and default value.
|
DoublePropertyType(Double defaultValue,
Double minValue,
Double maxValue)
Constructor with minimum and maximum value.
|
| Modifier and Type | Method and Description |
|---|---|
Double |
getMaxValue()
Gets the max value (inclusive) a value may be.
|
Double |
getMinValue()
Gets the min value (inclusive) a value may be.
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
boolean |
isUseMaxValue()
Determines if max value restriction is used.
|
boolean |
isUseMinValue()
Determines if min value restriction is used.
|
void |
setMaxValue(Double maxValue)
Sets the max value (inclusive) a value may be.
|
void |
setMinValue(Double minValue)
Sets the min value (inclusive) a value may be.
|
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
void |
validateIsInRange(String propertyName,
Double 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.
|
Double |
validateValue(String propertyName,
String value)
Converts the string representation of to a typed value.
|
equals, getDefaultValue, getDefaultValueAsString, getDefaultValueDescription, getDescription, getDescription, getInitializationPriority, getIo, getLogger, getTypeName, hasDefaultValue, isDefaultValueValid, postGetValueProcessing, setDefaultValue, setInitializationPriority, setIo, setTypedValue, setTypeName, toString, toType, validate, validateNullTypepublic static final String TYPE
public DoublePropertyType()
public DoublePropertyType(double defaultValue)
defaultValue - default value returned if property value is undefined.public DoublePropertyType(Double defaultValue)
defaultValue - default value returned if property value is undefined.public DoublePropertyType(double minValue,
double maxValue)
minValue - minimum value, inclusive.maxValue - maximum value, inclusive.public DoublePropertyType(double defaultValue,
double minValue,
double maxValue)
defaultValue - default value returned if property value is undefined.minValue - minimum value, inclusive.maxValue - maximum value, inclusive.public DoublePropertyType(Double minValue, Double maxValue)
minValue - minimum value, inclusive, if is null than it means no default value.maxValue - maximum value, inclusive, if is null than it means no default value.public DoublePropertyType(Double defaultValue, Double minValue, Double maxValue)
defaultValue - default value returned if property value is undefined.minValue - minimum value, inclusive, if is null than it means no default value.maxValue - maximum value, inclusive, if is null than it means no default value.public List<String> getRestrictions()
PropertyTypegetRestrictions in class PropertyType<Double>public Double validateValue(String propertyName, String value) throws PropertyException
PropertyTypevalidateValue in class PropertyType<Double>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 void validateConstraints(String propertyName) throws PropertyException
PropertyTypevalidateConstraints in class PropertyType<Double>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 void validateIsInRange(String propertyName, Double value) throws PropertyException
RangevalidateIsInRange in interface Range<Double>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<Double>propertyName - the name of the property.PropertyException - if minValue is greather than maxValue.PropertyType.validateConstraints(String)public Double getMaxValue()
getMaxValue in interface Range<Double>public Double getMinValue()
getMinValue in interface Range<Double>public void setMinValue(Double minValue)
setMinValue in interface Range<Double>minValue - the min value.public void setMaxValue(Double maxValue)
setMaxValue in interface Range<Double>maxValue - the max value.public boolean isUseMinValue()
isUseMinValue in interface Range<Double>true if min value is not null, otherwise false.public boolean isUseMaxValue()
isUseMaxValue in interface Range<Double>true if max value is not null, otherwise false.