Jackson + Builder Pattern?
- by Gili
I'd like Jackson to deserialize a class with the following constructor:
public Clinic(String name, Address address)
Deserializing the first argument is easy. The problem is that Address is defined as:
public class Address
{
private Address(Map<LocationType, String> components)
...
public static Builder
{
public Builder setCity(String value);
public Builder setCountry(String value);
public Address create();
}
}
and is constructed like this: new Address.Builder().setCity("foo").setCountry("bar").create();
Is there a way to get key-value pairs from Jackson in order to construct the Address myself? Alternatively, is there a way to get Jackson to use the Builder class itself?