スーパークラスに一連の共有プロパティを持つオブジェクトがいくつかあります。
public Superclass {
int id;
String name;
...
}
そして、スーパークラスから継承するサブクラスがありますが、それぞれに完全に記述された独自の @JsonCreator が必要です
public Subclass1 extends Superclass {
String color;
@JsonCreator
public Subclass1(@JsonProperty("id") int id,
@JsonProperty("name") String name,
@JsonProperty("color") String color)
{
super(id, name);
this.color = color;
}
}
public Subclass2 extends Superclass {
int height;
@JsonCreator
public Subclass1(@JsonProperty("id") int id,
@JsonProperty("name") String name,
@JsonProperty("height") int height)
{
super(id, name);
this.height = height;
}
}
Jackson (2.x) が期待される JSON フィールドに関する情報をスーパークラスから取得し、この繰り返しを回避する方法はありますか?