-
Notifications
You must be signed in to change notification settings - Fork 5
/
MapStringDefaults.java
25 lines (20 loc) · 955 Bytes
/
MapStringDefaults.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
package org.genericsystem.reactor.contextproperties;
import java.util.function.Function;
import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.HtmlDomNode;
import org.genericsystem.reactor.Tag;
import javafx.collections.FXCollections;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableMap;
public interface MapStringDefaults extends ContextProperty {
default ObservableMap<String, String> getDomNodeMap(Context model, String propertyName, Function<HtmlDomNode, MapChangeListener<String, String>> getListener) {
if (!model.containsProperty((Tag) this, propertyName)) {
createNewInitializedProperty(propertyName, model, m -> {
ObservableMap<String, String> map = FXCollections.observableHashMap();
map.addListener(getListener.apply(model.getHtmlDomNode((Tag) this)));
return map;
});
}
return (ObservableMap<String, String>) getProperty(propertyName, model).getValue();
}
}