@Test public void atLeastTest() { SelectionLengthValidator<Integer> s = SelectionLengthValidator.atLeast(2, "test"); Assert.assertTrue(s.validate(FXCollections.observableArrayList(1, 4)).getResult()); Assert.assertFalse(s.validate(FXCollections.observableArrayList(1)).getResult()); Assert.assertFalse(s.validate(FXCollections.observableArrayList()).getResult()); Assert.assertTrue(s.validate(FXCollections.observableArrayList(1, 2, 3)).getResult()); try { SelectionLengthValidator s2 = SelectionLengthValidator.atLeast(-10, "test"); fail(); } catch (IllegalArgumentException ignored) {} try { SelectionLengthValidator s3 = SelectionLengthValidator.atLeast(0, "test"); } catch (IllegalArgumentException e) { fail(); } }
public static <T> SelectionLengthValidator<T> atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new SelectionLengthValidator<>(min, Integer.MAX_VALUE, errorMessage); }
SelectionLengthValidator extends CustomValidator<ObservableList<E>> { public static <T> SelectionLengthValidator<T> atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new SelectionLengthValidator<>(min, Integer.MAX_VALUE, errorMessage); } }
SelectionLengthValidator extends CustomValidator<ObservableList<E>> { public static <T> SelectionLengthValidator<T> atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new SelectionLengthValidator<>(min, Integer.MAX_VALUE, errorMessage); } private  SelectionLengthValidator(int min, int max, String errorMessage); }
SelectionLengthValidator extends CustomValidator<ObservableList<E>> { public static <T> SelectionLengthValidator<T> atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new SelectionLengthValidator<>(min, Integer.MAX_VALUE, errorMessage); } private  SelectionLengthValidator(int min, int max, String errorMessage); static SelectionLengthValidator<T> between(int min, int max, String errorMessage); static SelectionLengthValidator<T> atLeast(int min, String errorMessage); static SelectionLengthValidator<T> upTo(int max, String errorMessage); static SelectionLengthValidator<T> exactly(int value, String errorMessage); }
SelectionLengthValidator extends CustomValidator<ObservableList<E>> { public static <T> SelectionLengthValidator<T> atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new SelectionLengthValidator<>(min, Integer.MAX_VALUE, errorMessage); } private  SelectionLengthValidator(int min, int max, String errorMessage); static SelectionLengthValidator<T> between(int min, int max, String errorMessage); static SelectionLengthValidator<T> atLeast(int min, String errorMessage); static SelectionLengthValidator<T> upTo(int max, String errorMessage); static SelectionLengthValidator<T> exactly(int value, String errorMessage);  }