public NumericConstraint(String name, boolean optional, Class dataType, Number minValue, Number maxValue)Creates a new instance of NumericConstraint. Note that since the values for min
and max have to be of type Number, the numberType class must likewise be a
descendant of that class otherwise the construction of the constraint wotn work.
super(name, optional, dataType);
if (!Number.class.isAssignableFrom(dataType)) {
throw new IllegalArgumentException(ERR_NOT_NUMBER);
}
if (!(minValue.getClass().equals(dataType))) {
throw new IllegalArgumentException(ERR_MISMATCH);
}
if (!(maxValue.getClass().equals(dataType))) {
throw new IllegalArgumentException(ERR_MISMATCH);
}
// ** validation done
this.minValue = minValue;
this.maxValue = maxValue;
|