public class RangeConstraint<T extends Comparable<T>> extends Constraint
Comparable
value is within the given range constraints.Modifier and Type | Field and Description |
---|---|
protected T |
mMax |
protected T |
mMin |
mErrorMessage
Constructor and Description |
---|
RangeConstraint(String pErrorMessage,
T pMin,
T pMax)
Creates a new range constraint based on these min an max values.
|
Modifier and Type | Method and Description |
---|---|
String |
describeError(Object pValue) |
T |
getMax() |
T |
getMin() |
boolean |
isValid(Object pValue)
Returns
true if the value is null or >= min value and <= max value. |
equals, hashCode, toString
protected final T extends Comparable<T> mMin
protected final T extends Comparable<T> mMax
public RangeConstraint(String pErrorMessage, T pMin, T pMax)
pMin
- may not be null
.pMax
- may not be null
.IllegalArgumentException
- if either min or max values are null
.public boolean isValid(Object pValue)
true
if the value is null
or >= min value and <= max value.isValid
in class Constraint
public String describeError(Object pValue)
describeError
in class Constraint
public T getMin()
public T getMax()
© 1998- 2021 Escenic AS