public class BigDecimalPropertyType extends PropertyType<BigDecimal> implements Range<BigDecimal>
java.math.BigDecimal. new BigDecimal(value);.
| Constructor Example | Comments | ||
|---|---|---|---|
| Property<BigDecimal> A_PROPERTY = new Property<BigDecimal>("name", new BigDecimalPropertyType()); |
No default value, no minimum or maximum constraints. | ||
Property<BigDecimal> A_PROPERTY = |
Default value is "-987654321987654321000000000.1234", no minimum or maximum constraints. | ||
Property<BigDecimal> A_PROPERTY = |
No default value,minimum is "187654321987654321000000000.1234" and maximum is "99987654321987654321000000000", both inclusive.. | ||
Property<BigDecimal> A_PROPERTY = |
Default value is "487654321987654321000000000.1234",minimum is "187654321987654321000000000.1234" and maximum is "99987654321987654321000000000.1234", both inclusive. | ||
| Type of value(s) | Examples | Result | Comments |
| Valid | -987654321987654321000000000.1234 | new BigDecimal(-987654321987654321000000000.1234) | Validate successfully. |
| Valid | 187654321987654321000000000.1234 | new BigDecimal(187654321987654321000000000.1234) | Validate successfully. |
| Invalid | cow | null |
Validate will throw an exception. The resulting value is null. |
| Invalid | 3.23 | 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. |
BigDecimal.BigDecimal(String),
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static String |
TYPE
The type name string constant of BigDecimalPropertyType
|
| Constructor and Description |
|---|
BigDecimalPropertyType()
Default constructor, no minimum, maximum or default value.
|
BigDecimalPropertyType(BigDecimal defaultValue)
Constructor with default value.
|
BigDecimalPropertyType(BigDecimal minValue,
BigDecimal maxValue)
Constructor with minimum and maximum value.
|
BigDecimalPropertyType(BigDecimal defaultValue,
BigDecimal minValue,
BigDecimal maxValue)
Constructor with minimum, maximum and default value.
|
| Modifier and Type | Method and Description |
|---|---|
BigDecimal |
getMaxValue()
Gets the max value (inclusive) a value may be.
|
BigDecimal |
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(BigDecimal maxValue)
Sets the max value (inclusive) a value may be.
|
void |
setMinValue(BigDecimal 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,
BigDecimal 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.
|
BigDecimal |
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 BigDecimalPropertyType()
public BigDecimalPropertyType(BigDecimal defaultValue)
defaultValue - default value returned if property value is undefined.public BigDecimalPropertyType(BigDecimal defaultValue, BigDecimal minValue, BigDecimal maxValue)
defaultValue - default value returned if property value is undefined, if is null than it means no default value.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 BigDecimalPropertyType(BigDecimal minValue, BigDecimal maxValue)
minValue - minimum value, inclusive.maxValue - maximum value, inclusive.public List<String> getRestrictions()
PropertyTypegetRestrictions in class PropertyType<BigDecimal>public BigDecimal validateValue(String propertyName, String value) throws PropertyException
PropertyTypevalidateValue in class PropertyType<BigDecimal>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<BigDecimal>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, BigDecimal value) throws PropertyException
RangevalidateIsInRange in interface Range<BigDecimal>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<BigDecimal>propertyName - the name of the property.PropertyException - if minValue is greather than maxValue.PropertyType.validateConstraints(String)public BigDecimal getMaxValue()
getMaxValue in interface Range<BigDecimal>public BigDecimal getMinValue()
getMinValue in interface Range<BigDecimal>public void setMinValue(BigDecimal minValue)
setMinValue in interface Range<BigDecimal>minValue - the min value.public void setMaxValue(BigDecimal maxValue)
setMaxValue in interface Range<BigDecimal>maxValue - the max value.public boolean isUseMinValue()
isUseMinValue in interface Range<BigDecimal>true if min value is not null, otherwise false.public boolean isUseMaxValue()
isUseMaxValue in interface Range<BigDecimal>true if max value is not null, otherwise false.