[
https://issues.apache.org/jira/browse/JOHNZON-200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16764726#comment-16764726
]
Romain Manni-Bucau commented on JOHNZON-200:
--------------------------------------------
Hi [~elexx], this is actually expected, we reused constructorproperties before
jsonb got a real solution (before it exists actually) but we sticked to
JohnzonProperty values (json)
> ConstructorProperties with custom-named fields (JohnzonProperty)
> ----------------------------------------------------------------
>
> Key: JOHNZON-200
> URL: https://issues.apache.org/jira/browse/JOHNZON-200
> Project: Johnzon
> Issue Type: Bug
> Components: Mapper
> Affects Versions: 1.1.11
> Reporter: Alexander Falb
> Priority: Minor
>
> I'm not sure if this is a bug or just unexpected behaviour:
> When I map a JSON field named "$version" to a Java field named "version" and
> this field is mandatory/final I have to annotate the constuctor like this:
> {code:java}
> public static class MyBean {
> @JohnzonProperty("$version") private final int version;
> @ConstructorProperties("$version") public MyBean(int version) {
> this.version = version;
> }
> ...{code}
> I would expect the value of {{ConstructorProperties}} to be {{version}}
> (without the dollar $ sign), because the documentation of
> {{ConstructorProperties}} says:
> {quote}An annotation on a constructor that shows how the parameters of
> that constructor correspond to the constructed object's getter
> methods. [...]
> {quote}
> but is actually has to be the JSON field name.
> In my optinion this is quite unexpected and also from a maintainability point
> of view I think declaring the custom naming twice is bad. - I think the
> {{ConstructorProperties}} should the the Java field names and not the JSON
> name (or for backward compatability maybe both).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)