[ 
https://issues.apache.org/jira/browse/JOHNZON-213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16864680#comment-16864680
 ] 

Jin Kwon commented on JOHNZON-213:
----------------------------------

[~romain.manni-bucau] Thank you.

I concluded that Apache Johnzon requires both getter and setter to be annotated 
with {{@JsonbTypeAdpater}}.

{code:java}
public class Child extends Parent<SomeOptions> {

    @JsonbTypeAdapter(SomeOptionsAdapter.class)
    @Override
    public SomeOptions getOptions() {
        return super.getOptions();
    }

//    @JsonbTypeAdapter(SomeOptionsAdapter.class)
    @Override
    public void setOptions(SomeOptions options) {
        super.setOptions(options);
    }
}
{code}

And I really want anyone to rethink about the meaning of accessing {{property}}.
When a field is supposed to be accessed via a term of {{property}} that means 
there will be standard accessors(getter and setter).
But that doesn't mean both accessors need to be annotated with same annotation.

Apache Johnzon must detect {{@JsonbTypeAdapter}} only from either from getter 
or from setter.

How about following example?

{code:java}
    @JsonbProperty
    public String getExposed() {
        return hidden;
    }

    //@JsonProperty // required? Johnzon works without it.
    public void setExposed(final String exposed) {
        this.hidden = exposed;
    }

    @JsonbTransient
    private String hidden = "hidden";
{code}

Should {{setExposed}} be annotated with {{@JsonbProperty}}?

> Make @JsonbTypeAdapter works with accessors
> -------------------------------------------
>
>                 Key: JOHNZON-213
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-213
>             Project: Johnzon
>          Issue Type: Bug
>          Components: JSON-B
>    Affects Versions: 1.1.12
>            Reporter: Jin Kwon
>            Priority: Major
>
> For some reasons, I need to annotate an overridden method with an 
> {{@JsonbTypeAdapter}}.
> {code:java}
> class Parent<T extends ...> {
>     T options;
> }
> class Child extends Parent<SomeOptions> {
>     @JsonbTypeAdapter(value = SomeOptionsTypeAdapter.class)
>     public SomeOptions getOptions() {
>         return super.getOptions();
>     } 
> }
> {code}
> Now Johnzon complains.
> {code}
> javax.json.bind.JsonbException: Missing a Converter for type class 
> ...Params$Options to convert the JSON String '{"..."}' . Please register a 
> custom converter for it.
> Caused by: org.apache.johnzon.mapper.MapperException: Missing a Converter for 
> type class ...Params$Options to convert the JSON String '{"..."}' . Please 
> register a custom converter for it.
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to