Jackson + Builder Pattern?

Posted by Gili on Stack Overflow See other posts from Stack Overflow or by Gili
Published on 2011-02-13T03:53:08Z Indexed on 2011/02/13 7:25 UTC
Read the original article Hit count: 336

Filed under:

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?

© Stack Overflow or respective owner

Related posts about jackson