T - public class RangeVO<T extends Comparable<T>> extends Object
T. T must extends Comparable<T>. | Constructor and Description |
|---|
RangeVO(PropertyType<T> rangeType,
T from,
T to,
String divider)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
String |
getDivider()
Gets the divider
|
T |
getFrom()
Gets the FROM value of type T.
|
PropertyType<T> |
getRangeType()
Gets the PropertyType which can convert a String to type T.
|
T |
getTo()
Gets the TO value of type T.
|
boolean |
isInRange(T value)
Validates if the value of type T is inside the range, FROM and TO is both inclusive.
|
boolean |
isStringInRange(String value)
Converts a string to a type T using the RangeType, is validates if it is inside the range, FROM and TO is both inclusive.
|
String |
toString()
Constructs a String version of the Range.
|
void |
validate(String propertyName)
Validates the attributes of this object instance.
|
public RangeVO(PropertyType<T> rangeType, T from, T to, String divider)
rangeType - the PropertyType which can convert a String to type T.from - the FROM value of type T, this must be less than or equal to TO.to - the TO value of type T, this must be greater than or equal to FROM.divider - the divider which is between FROM and TO, is must be not null and none empty.public PropertyType<T> getRangeType()
public final T getFrom()
T.public final T getTo()
T.public final String getDivider()
public void validate(String propertyName) throws PropertyException
propertyName - the name of the Property of which this instance belongs to.PropertyException - if either RangeType, FROM or TO is null, or FROM is greater than TO.public String toString()
public boolean isInRange(T value)
value - the the value of type T.true if the value is inside the FROM and TO range. If value is null, than false is returned.public boolean isStringInRange(String value)
value - the string valuetrue if the string value is succesfully converted to type T and is inside the range, otherwise false.isInRange(Comparable)