jsr367-experts@jsonb-spec.java.net

[jsr367-experts] Re: Polymorphism support

From: Roman Grigoriadi <roman.grigoriadi_at_oracle.com>
Date: Fri, 1 Apr 2016 11:01:50 +0200

Hi,

I think we need to reconsider what are the usecases (besides
polymorphism), that cannot be handled efficiently with adapters. Can you
please provide such code examples describing the limitations of adapters
in their current state? I still have a feeling I am not on the same
note, to render what the problem with adapters actually is.

Thanks,
Roman

On 04/01/2016 08:00 AM, Romain Manni-Bucau wrote:
>
> Hi Dmitry
>
> Think the topic is not polymorphism but advanced adapter. Polymorphism
> is one example of that only.
>
> The last proposal of Roman needs some rework - see my last mail with
> JsonbObjectBuilder - but we move forward and in the right direction:
> making easy from/to map to jsonp objects - including objects directly
> and not primitives only - is what makes sense and gives us all the
> flexibility. Makes a bit harder to implement trivial cases but here it
> is easy to add to the spec an abstrat class skipping jsonp (for object
> to primitive mapping if we judge it too verbose using a JsonValue bit
> I think it can be optional for jsonb 1.0)
>
> I am really for fixing adapter API and not making polymorphism a
> particular case of the spec.
>
> Le 31 mars 2016 23:46, "Dmitry Kornilov" <dmitry.kornilov_at_oracle.com
> <mailto:dmitry.kornilov_at_oracle.com>> a écrit :
>
> Hi,
>
> I see that polymorphism discussion is still on. I am planning to
> publish a second draft soon so we need to make a decision rather
> sooner than later.
>
> I see that we have three options:
>
> 1. We don’t support polymorphism in this version of the spec. We
> still can add it later.
>
> 2. We add PolymorphicAdapter suggested by Roman to the spec.
>
> 3. We create a special annotation @JsonbPolymorphism (or other
> name) which will enable polymorphic handling of the annotated
> type. It can accept a list of supported children as a parameter.
> Empty list means all children.
>
> Sample:
>
> public class Foo {
>
> @JsonbPolymorphism
> Animal animal;
> }
>
> For me the third option looks the most reasonable one. What do you
> think?
>
> Thanks,
> Dmitry
>