In the model class there are two types of Property : SimpleStringProperty and SimpleIntegerProperty . It is necessary to display them in the form of a TableView , where the first column is the name of the value (description), and the second is the value itself. Something like this:
The data of the model class is packaged in Map<String,Property<?>> , where key is the name of the value, and value is Property with the value.
Interested in the following:
1) What should CellValueFactory look like so that the values ​​are correctly "zabindeny", i.e. if necessary, they could be changed in the table and the changes were reflected in the class-model.
2) Are the generics correct in the map-package?
UPD: Added an intermediate class to resolve this issue, but I think that the “crutch” turned out:
public class PropertiesContainer { private String propName; private SimpleIntegerProperty concreteIntSourceProperty=null; private SimpleStringProperty concreteStrSourceProperty=null; private SimpleStringProperty destProperty; public PropertiesContainer(String propName, Property<?> property) { this.propName = propName; if (property.getClass().equals(SimpleStringProperty.class)){ concreteStrSourceProperty = (SimpleStringProperty) property; destProperty = new SimpleStringProperty(concreteStrSourceProperty.get()); } else if (property.getClass().equals(SimpleIntegerProperty.class)) { concreteIntSourceProperty = (SimpleIntegerProperty) property; destProperty = new SimpleStringProperty(Integer.toString(concreteIntSourceProperty.get())); } destProperty.addListener((observable, oldValue, newValue) -> { if (concreteIntSourceProperty!=null) concreteIntSourceProperty.set(Integer.valueOf(newValue)); else concreteStrSourceProperty.set(newValue); }); } public String getDestProperty() { return destProperty.get(); } public SimpleStringProperty destProperty() { return destProperty; } public String getPropName() { return propName; } } 