Why not make a model that wraps a Map from String keys to Object values? Or, if the values are always the same type, no need to refer to them as Object. Or make the model just Map<String, Object>?
The ValueProvider is just an interface - you can make a ValueProvider any way you want, including one that takes a string and uses that to ask the model for an object. This would act on a Map:
Code:
class MapValueProvider implements ValueProvider<Map<String, String>, String> {
private final String key;
public MapValueProvider(String key) {
this.key = key;
}
public String getValue(Map<String, String> object) {
return object.get(key);
}
public void setValue(Map<String, String> object, String value) {
object.put(key, value);
}
public String getPath() {
return key;
}
}
This could be reused whenever you are reading data from a map. It would need to be adapted of course for a model object that wraps a map, but those changes should be clear.
This could be used like this when making columnConfig instances:
Code:
new ColumnConfig<Map<String, String>, String>(new MapValueProvider("name"), ...);