private static Validator[] createFromDigits(DigitsConstraintInfo digits, PrimitiveType type) {
FloatPrecisionValidator floatPrecision = new FloatPrecisionValidator();
floatPrecision.setPrecision(digits.getFractional());
floatPrecision.setRoundToPrecision(digits.getFractional());
IntegerRangeValidator integerDigit = null;
FloatRangeValidator floatDigit = null;
Validator[] validators;
switch (type) {
case SHORT:
case INTEGER:
case LONG:
integerDigit = new IntegerRangeValidator();
integerDigit.setMax((int) Math.pow(10.0, digits.getInteger()) - 1);
validators = new Validator[] { floatPrecision, integerDigit };
break;
case FLOAT:
case DOUBLE:
floatDigit = new FloatRangeValidator();
floatDigit.setMax((int) Math.pow(10.0, digits.getInteger()) - Float.MIN_VALUE);
validators = new Validator[] { floatPrecision, floatDigit };
break;
default:
validators = new Validator[] { floatPrecision };
}