I am looking for the simplest way to do a deep copy of a flat Map<String, String> of nested properties to a bean. Some of the nested properties are interfaces for which I would like to provide a strategy for instantiation. For example:
Map<String, String> customer = new Map<String, String>();
customers.put("id", "123");
customers.put("address.line1", "221B Baker St.");
public class Customer {
private int id;
private Address address; //address is an interface
... getters/setters ...
}
Note that I do not want to supply explicit mappings, just a strategy for providing a concrete instance for the interface. I assumed that commons-beanutils to do this, but their is a open JIRA ticket for the functionality. A library that has similar functionality is Google GSON which provides an interface called InstanceCreator.
I've implemented a solution on top of beanutils, but is there a bean conversion library that has this functionality built in?