@Test public void betweenTest() { DoubleRangeValidator i = DoubleRangeValidator.between(3.5, 12.1351, "test"); Assert.assertTrue(i.validate(11.5).getResult()); Assert.assertTrue(i.validate(3.50000001).getResult()); Assert.assertFalse(i.validate(12.13511).getResult()); Assert.assertFalse(i.validate(3.4999999).getResult()); try { DoubleRangeValidator i2 = DoubleRangeValidator.between(10.0, 5.3, "test"); fail(); } catch (IllegalArgumentException ignored) {} try { DoubleRangeValidator i2 = DoubleRangeValidator.between(5.5, 5.5, "test"); } catch (IllegalArgumentException ignored) { fail(); } }
public static DoubleRangeValidator between(double min, double max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new DoubleRangeValidator(min, max, errorMessage); }
DoubleRangeValidator extends CustomValidator<Double> { public static DoubleRangeValidator between(double min, double max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new DoubleRangeValidator(min, max, errorMessage); } }
DoubleRangeValidator extends CustomValidator<Double> { public static DoubleRangeValidator between(double min, double max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new DoubleRangeValidator(min, max, errorMessage); } private  DoubleRangeValidator(double min, double max, String errorMessage); }
DoubleRangeValidator extends CustomValidator<Double> { public static DoubleRangeValidator between(double min, double max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new DoubleRangeValidator(min, max, errorMessage); } private  DoubleRangeValidator(double min, double max, String errorMessage); static DoubleRangeValidator between(double min, double max, String errorMessage); static DoubleRangeValidator atLeast(double min, String errorMessage); static DoubleRangeValidator upTo(double max, String errorMessage); static DoubleRangeValidator exactly(double value, String errorMessage); }
DoubleRangeValidator extends CustomValidator<Double> { public static DoubleRangeValidator between(double min, double max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new DoubleRangeValidator(min, max, errorMessage); } private  DoubleRangeValidator(double min, double max, String errorMessage); static DoubleRangeValidator between(double min, double max, String errorMessage); static DoubleRangeValidator atLeast(double min, String errorMessage); static DoubleRangeValidator upTo(double max, String errorMessage); static DoubleRangeValidator exactly(double value, String errorMessage);  }