T
- which must implement Comparable of type T.public class RangePropertyType<T extends Comparable<T>> extends PropertyType<RangeVO<T>> implements MarkerSubPropertyType
T
.T
must extends Comparable<T>
. Constructor Example | Comments | ||
---|---|---|---|
Property<RangeVO<Integer>> P_MY_INT_RANGE = |
A RangePropertyType where FROM and TO is of type Integer, with no default value and ";" as default divider. | ||
Property<RangeVO<Date>> P_MY_DATE_RANGE = new Property<RangeVO<Date>>("p.property.name",new RangePropertyType<Date>(new DateTimePropertyType(),"-")); |
A RangePropertyType where FROM and TO is of type Date, with no default value and "-" as divider | ||
Type of value(s) | Examples | Result | Comments |
Valid | 1-3 | new RangeVO<Integer>(new IntegerPropertyType(),1,3,"-") | Validate successfully. |
Invalid | null |
Validate will throw an exception. The resulting value is null . |
|
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 . |
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DIVIDER
The default divider ";".
|
static String |
TYPE
The type name string constant of BooleanPropertyType.
|
Constructor and Description |
---|
RangePropertyType()
Constructor where divider is set to ";" and default value is
null . |
RangePropertyType(PropertyType<T> rangeType)
Constructor where divider is set to ";" and default value is
null . |
RangePropertyType(PropertyType<T> rangeType,
RangeVO<T> defaultValue)
Constructor where divider is set to ";".
|
RangePropertyType(PropertyType<T> rangeType,
RangeVO<T> defaultValue,
String divider)
Constructor.
|
RangePropertyType(PropertyType<T> rangeType,
String divider)
Constructor where default value is
null . |
Modifier and Type | Method and Description |
---|---|
String |
getDivider()
The divider
|
PropertyType<T> |
getRangeType()
Gets the RangeType which return type T for the FROM and TO values.
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
void |
setDivider(String divider)
Sets the divider.
|
void |
setRangeType(PropertyType<T> rangeType)
Sets the range type.
|
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
RangeVO<T> |
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, validateNullType
public static final String TYPE
public static final String DEFAULT_DIVIDER
public RangePropertyType()
null
. public RangePropertyType(PropertyType<T> rangeType)
null
.rangeType
- an instance of a PropertyType of type T.public RangePropertyType(PropertyType<T> rangeType, RangeVO<T> defaultValue)
rangeType
- an instance of a PropertyType of type T.defaultValue
- default value returned if property value is undefined.public RangePropertyType(PropertyType<T> rangeType, String divider)
null
.rangeType
- divider
- the divider of the two string tokens. Be aware that it do not conflict with the string version of the type T. Must be not null
and none empty.public RangePropertyType(PropertyType<T> rangeType, RangeVO<T> defaultValue, String divider)
rangeType
- an instance of a PropertyType of type T.defaultValue
- defaultValue default value returned if property value is undefined.divider
- the divider of the two string tokens. Be aware that it do not conflict with the string version of the type T. Must be not null
and none empty.public String getDivider()
public void setDivider(String divider)
divider
- a new divider string. Must be not null
and none empty.public PropertyType<T> getRangeType()
public void setRangeType(PropertyType<T> rangeType)
rangeType
- a new range type of type T.public List<String> getRestrictions()
PropertyType
getRestrictions
in class PropertyType<RangeVO<T extends Comparable<T>>>
public RangeVO<T> validateValue(String propertyName, String value) throws PropertyException
PropertyType
validateValue
in class PropertyType<RangeVO<T extends Comparable<T>>>
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
PropertyType
validateConstraints
in class PropertyType<RangeVO<T extends Comparable<T>>>
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()