Is it possible to have the @JsonProperty required dynamically set or set at call?
The reason behind this... I'm generating json files which describes a schema and defines
- What are the required fields for a new item
- What are the required fields for an update to an item.
So, a creation requires only foo
and an update requires foo and bar
Can I make things so I can pass in something to say bar is now required?
or would I need to duplicate this code in order to have different settings for JsonProperty?
@JsonInclude(Include.NON_NULL)
public class Bean {
@JsonProperty(value="foo", required=false)
private FooProperty fooProperty;
@JsonProperty(value="bar", required=false)
private BarProperty barProperty;
//
public FooProperty getFooProperty() { return fooProperty; }
public void setFooProperty(FooProperty argFooProperty) {
this.fooProperty = argFooProperty
}
public BarProperty getBarProperty() { return barProperty; }
public void setFooProperty(BarProperty argBarProperty) {
this.barProperty = argBarProperty
}
}
@JsonAnyGetter
and@JsonAnySetter
a viable option for you? – Coder