package moe.tristan.easyfxml.util;

import java.util.function.Consumer;
import java.util.function.Supplier;

import javafx.beans.property.Property;

public final class Properties {

    private Properties() {
    }

    public static <T, P extends Property<T>> P newPropertyWithCallback(Supplier<P> propertyFactory, Consumer<T> callback) {
        final P property = propertyFactory.get();
        whenPropertyIsSet(property, callback);
        return property;
    }

    public static <T, P extends Property<T>> void whenPropertyIsSet(P property, Consumer<T> doWhenSet) {
        property.addListener((o, prev, cur) -> doWhenSet.accept(cur));
        if (property.getValue() != null) {
            doWhenSet.accept(property.getValue());
        }
    }

}

@@ -563,24 +563,215 @@
 oWhenSet) %7B%0A
+        whenPropertyIsSet(property, () -%3E doWhenSet.accept(property.getValue()));%0A    %7D%0A%0A    public static %3CT, P extends Property%3CT%3E%3E void whenPropertyIsSet(P property, Runnable doWhenSet) %7B%0A
         prop
@@ -819,18 +819,12 @@
 Set.
-accept(cur
+run(
 ));%0A
@@ -892,34 +892,12 @@
 Set.
-accept(property.getValue()
+run(
 );%0A 

Add basic convenience async property runnable execution