### Question:
ObservableRules { public static ObservableBooleanValue matches(ObservableValue<String> source, Pattern pattern) { return Bindings.createBooleanBinding(() -> { final String s = source.getValue(); return s != null && pattern.matcher(s).matches(); }, source); }  static ObservableBooleanValue fromPredicate(ObservableValue<T> source, Predicate<T> predicate); static ObservableBooleanValue notEmpty(ObservableValue<String> source); static ObservableBooleanValue matches(ObservableValue<String> source, Pattern pattern);  }### Answer:
@Test public void testMatches() { StringProperty value = new SimpleStringProperty(); final ObservableBooleanValue rule = ObservableRules.matches(value, Pattern.compile("[0-9]")); assertThat(rule.get()).isFalse(); value.set("1"); assertThat(rule.get()).isTrue(); value.set("55"); assertThat(rule.get()).isFalse(); value.set("5"); assertThat(rule.get()).isTrue(); value.set(null); assertThat(rule.get()).isFalse(); }