@Test public void betweenTest() { IntegerRangeValidator i = IntegerRangeValidator.between(10, 20, "test"); Assert.assertTrue(i.validate(14).getResult()); Assert.assertFalse(i.validate(21).getResult()); Assert.assertTrue(i.validate(20).getResult()); Assert.assertTrue(i.validate(10).getResult()); try { IntegerRangeValidator i2 = IntegerRangeValidator.between(20, 10, "test"); fail(); } catch (IllegalArgumentException ignored) {} try { IntegerRangeValidator i2 = IntegerRangeValidator.between(10, 10, "test"); } catch (IllegalArgumentException ignored) { fail(); } }
public static IntegerRangeValidator between(int min, int max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new IntegerRangeValidator(min, max, errorMessage); }
IntegerRangeValidator extends CustomValidator<Integer> { public static IntegerRangeValidator between(int min, int max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new IntegerRangeValidator(min, max, errorMessage); } }
IntegerRangeValidator extends CustomValidator<Integer> { public static IntegerRangeValidator between(int min, int max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new IntegerRangeValidator(min, max, errorMessage); } private  IntegerRangeValidator(int min, int max, String errorMessage); }
IntegerRangeValidator extends CustomValidator<Integer> { public static IntegerRangeValidator between(int min, int max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new IntegerRangeValidator(min, max, errorMessage); } private  IntegerRangeValidator(int min, int max, String errorMessage); static IntegerRangeValidator between(int min, int max, String errorMessage); static IntegerRangeValidator atLeast(int min, String errorMessage); static IntegerRangeValidator upTo(int max, String errorMessage); static IntegerRangeValidator exactly(int value, String errorMessage); }
IntegerRangeValidator extends CustomValidator<Integer> { public static IntegerRangeValidator between(int min, int max, String errorMessage) { if (min > max) { throw new IllegalArgumentException("Minimum must not be larger than maximum."); } return new IntegerRangeValidator(min, max, errorMessage); } private  IntegerRangeValidator(int min, int max, String errorMessage); static IntegerRangeValidator between(int min, int max, String errorMessage); static IntegerRangeValidator atLeast(int min, String errorMessage); static IntegerRangeValidator upTo(int max, String errorMessage); static IntegerRangeValidator exactly(int value, String errorMessage);  }