jsonb-api
jsonb-api copied to clipboard
JsonbTypeAdapter missing ElementType.PARAMETER
It does not appear JsonbTypeAdapter can be used everywhere JsonbProperty can be used.
Imagine we have this field-based class
public class Source {
@JsonbProperty("className")
private String className;
@JsonbProperty("path")
@JsonbTypeAdapter(FileAdapter.class)
private File path;
@JsonbProperty("packageName")
private String packageName;
@JsonbProperty("imports")
private List<String> imports;
//...
We decide that we instead want to have final variables and use a constructor via JsonbCreator as such:
public class Source {
private final String className;
private final File path;
private final String packageName;
private final List<String> imports;
@JsonbCreator
public Source(@JsonbProperty("className") final String className,
@JsonbProperty("path") final File path,
@JsonbProperty("packageName") final String packageName,
@JsonbProperty("imports") final List<String> imports) {
this.className = className;
this.path = path;
this.packageName = packageName;
this.imports = imports;
}
//...
The limitation that prevents this from working appears to be that @JsonbTypeAdapter cannot "follow" the other annotations and be placed on the appropriate constructor parameter.
+1 this is a sibling issue of https://github.com/eclipse-ee4j/jsonb-api/issues/197 (generally speaking we should ensure any field annotation supports parameter)
@dblevins workaround is to add -parameters to javac ;)
+1 seems reasonable and straightforward to me
With https://github.com/eclipse-ee4j/jsonb-api/issues/71 getting fixed, any chance of this getting in as well for the next version?