@Test public void testNumericIntervalConstraintHandleString() { assertTrue(minInMaxEx.validate("3")); assertFalse(minInMaxEx.validate("5")); }
@Override public boolean validate(Object object) { BigDecimal val = ConstraintUtils.objectToBigDecimal(object); if (val == null) { return true; } if (min != null) { int test = min.compareTo(val); if (test > 0) { return false; } if (!includingMin && test == 0) { return false; } } if (max != null) { int test = max.compareTo(val); if (test < 0) { return false; } if (!includingMax && test == 0) { return false; } } return true; }
NumericIntervalConstraint extends AbstractConstraint { @Override public boolean validate(Object object) { BigDecimal val = ConstraintUtils.objectToBigDecimal(object); if (val == null) { return true; } if (min != null) { int test = min.compareTo(val); if (test > 0) { return false; } if (!includingMin && test == 0) { return false; } } if (max != null) { int test = max.compareTo(val); if (test < 0) { return false; } if (!includingMax && test == 0) { return false; } } return true; } }
NumericIntervalConstraint extends AbstractConstraint { @Override public boolean validate(Object object) { BigDecimal val = ConstraintUtils.objectToBigDecimal(object); if (val == null) { return true; } if (min != null) { int test = min.compareTo(val); if (test > 0) { return false; } if (!includingMin && test == 0) { return false; } } if (max != null) { int test = max.compareTo(val); if (test < 0) { return false; } if (!includingMax && test == 0) { return false; } } return true; } NumericIntervalConstraint(Object min, boolean includingMin, Object max, boolean includingMax); }
NumericIntervalConstraint extends AbstractConstraint { @Override public boolean validate(Object object) { BigDecimal val = ConstraintUtils.objectToBigDecimal(object); if (val == null) { return true; } if (min != null) { int test = min.compareTo(val); if (test > 0) { return false; } if (!includingMin && test == 0) { return false; } } if (max != null) { int test = max.compareTo(val); if (test < 0) { return false; } if (!includingMax && test == 0) { return false; } } return true; } NumericIntervalConstraint(Object min, boolean includingMin, Object max, boolean includingMax); @Override boolean validate(Object object); @Override Description getDescription(); BigDecimal getMin(); BigDecimal getMax(); boolean isIncludingMin(); boolean isIncludingMax(); @Override String getErrorMessage(Object invalidValue, Locale locale); @Override int hashCode(); @Override boolean equals(Object obj); }
NumericIntervalConstraint extends AbstractConstraint { @Override public boolean validate(Object object) { BigDecimal val = ConstraintUtils.objectToBigDecimal(object); if (val == null) { return true; } if (min != null) { int test = min.compareTo(val); if (test > 0) { return false; } if (!includingMin && test == 0) { return false; } } if (max != null) { int test = max.compareTo(val); if (test < 0) { return false; } if (!includingMax && test == 0) { return false; } } return true; } NumericIntervalConstraint(Object min, boolean includingMin, Object max, boolean includingMax); @Override boolean validate(Object object); @Override Description getDescription(); BigDecimal getMin(); BigDecimal getMax(); boolean isIncludingMin(); boolean isIncludingMax(); @Override String getErrorMessage(Object invalidValue, Locale locale); @Override int hashCode(); @Override boolean equals(Object obj);  }