This repository was archived by the owner on Jan 22, 2019. It is now read-only.
This repository was archived by the owner on Jan 22, 2019. It is now read-only.
Leverage java 8 Parameter Name support to allow @JsonCreator to be used for schema generation #86
Open
Description
Is it possible with Parameter Name support an @JsonCreator annotated constructor could be all that is needed to manage column order and header names?
This would save lots of duplicate and easy to mess up @JsonProperty code.
Users would be required to have their parameter names match their field/accessors names.
Current Code:
@JsonPropertyOrder({ "E-Trade ID", "MY-Trade ID" })
public static class EtradeAccount {
@JsonProperty("E-Trade ID")
private final String eTradeId;
@JsonProperty("MY-Trade ID")
private final String myTradeId;
@JsonCreator
public EtradeAccount(@JsonProperty("E-Trade ID") String eTradeId, @JsonProperty("MY-Trade ID") String myTradeId) {
super();
this.eTradeId = eTradeId;
this.myTradeId = myTradeId;
}
//Workaround single character acronym issue
@JsonProperty("E-Trade ID")
public String getETradeId() {
return this.eTradeId;
}
public String getMyTradeId() {
return this.myTradeId;
}
}
Leveraging @JsonCreator and Parameter Names
public static class EtradeAccount {
private final String eTradeId;
private final String myTradeId;
@JsonCreator
public EtradeAccount( @JsonProperty("E-Trade ID") String eTradeId, @JsonProperty("MY-Trade ID") String myTradeId) {
super();
this.eTradeId = eTradeId;
this.myTradeId = myTradeId;
}
public String getETradeId() {
return this.eTradeId;
}
public String getMyTradeId() {
return this.myTradeId;
}
}```
Metadata
Metadata
Assignees
Labels
No labels