我希望 Jackson 用以下构造函数反序列化一个类:
public Clinic(String name, Address address)
反序列化第一个参数很容易,问题是 Address 被定义为:
public class Address {
private Address(Map<LocationType, String> components)
...
public static class Builder {
public Builder setCity(String value);
public Builder setCountry(String value);
public Address create();
}
}
结构如下: new Address.Builder().setCity("foo").setCountry("bar").create();
有没有办法从杰克逊那里获得键值对,以便自己构建地址?或者,有没有办法让 Jackson 使用 Builder 类本身?