### Question:
Properties { public static <T, P extends ObservableValue<T>> P newPropertyWithCallback(Supplier<P> propertyFactory, Consumer<T> callback) { final P property = propertyFactory.get(); whenPropertyIsSet(property, callback); return property; } private  Properties(); static P newPropertyWithCallback(Supplier<P> propertyFactory, Consumer<T> callback); static void whenPropertyIsSet(P property, Consumer<T> doWhenSet); static void whenPropertyIsSet(P property, Function<A, B> adapter, Consumer<B> doWhenSet); static void bind(ObservableValue<S> from, Function<S, C> adapter, Property<C> to); static void whenPropertyIsSet(P property, Runnable doWhenSet);  }### Answer:
@Test public void shouldCallDirectlyIfSetWithValue() { final Object element = new Object(); final Property<Object> called = new SimpleObjectProperty<>(null); Properties.newPropertyWithCallback(() -> new SimpleObjectProperty<>(element), called::setValue); assertThat(called.getValue()).isSameAs(element); }
@Test public void shouldCallConsumerOnEverySetCall() { final Property<Integer> called = new SimpleObjectProperty<>(); final Property<Integer> property = Properties.newPropertyWithCallback(SimpleObjectProperty::new, called::setValue); assertThat(called.getValue()).isNull(); IntStream.range(0, 1000).forEach(value -> { property.setValue(value); assertThat(called.getValue()).isEqualTo(value); }); }