-
Notifications
You must be signed in to change notification settings - Fork 5
/
ConvertedValueDefaults.java
40 lines (29 loc) · 1.15 KB
/
ConvertedValueDefaults.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.genericsystem.reactor.aa_modelproperties;
import java.io.Serializable;
import java.util.function.BiConsumer;
import java.util.function.Function;
import org.genericsystem.reactor.Context;
import javafx.beans.property.Property;
import javafx.beans.value.ObservableValue;
public interface ConvertedValueDefaults extends ContextProperty {
public static final String VALUE = "value";
public static final String INVALID = "invalid";
default void createConvertedValueProperty() {
createNewProperty(VALUE);
}
default Property<Serializable> getConvertedValueProperty(Context model) {
return getProperty(VALUE, model);
}
default <T> void initValueProperty(Function<Context, T> getInitialValue) {
initProperty(VALUE, getInitialValue);
}
default <T extends Serializable> void addConvertedValueChangeListener(BiConsumer<Context, T> listener) {
addPropertyChangeListener(VALUE, listener);
}
default <T> void storeInvalidProperty(Function<Context, ObservableValue<T>> applyOnModel) {
storeProperty(INVALID, applyOnModel);
}
default ObservableValue<Boolean> getInvalidObservable(Context model) {
return getObservableValue(INVALID, model);
}
}