Skip to content

'Bundled' @JsonView annotations should merge #38

Open

Description

@davideanderson

I have created two annotation bundles:

...
@JsonView(view1.class)
@JacksonAnnotationsInside
...
public @interface bundle1 {
...

and

...
@JsonView(view2.class)
@JacksonAnnotationsInside
...
public @interface bundle2 {
...

Then I apply the annotations to properties, like this:

@bundle1
String prop1

@bundle2
int prop2

@bundle1
@bundle2
boolean prop3

I would like it if the @JSONVIEW annotations be merged for prop3 (becoming the equivalent of @JSONVIEW({view1.class, view2.class})). Right now it appears that one of the them overwrites the other one.

Alternatively, if there is another way of doing what I am trying, I would appreciate that. I know I could create a 3rd annotation named bundle1and2, but that is a bit ugly and I end up with duplicate code. I know I can also remove the @JSONVIEW from the bundles and separate it out and use @JSONVIEW({view1.class, view2.class}), but I don't want to do that either as I would prefer the views to be encapsulated in the bundles.

Activity

  1. cowtowncoder commented on Jun 18, 2014

    @cowtowncoder
    Member

    Interesting. Yes, I could see why it would make sense.

    Similar merging would make sense for some other annotations, like:

    • @JsonIgnoreProperties (when listing properties)
    • @JsonSubTypes (to combine sets of subtypes)

    and probably others I can't think of now. For others it may be necessary to simply take one of the lists, as there is no meaningful way to merge values contained.

    I'll have to figure out how feasible this is to do; if all goes well, it could get added in 2.5 (I expect some changes to internal APIs are needed).

  2. davideanderson commented on Jun 18, 2014

    @davideanderson
    Author

    That would be great if it works out. Also, it is great how quickly you respond to issues. It is very appreciated.

  3. cowtowncoder commented on Jun 18, 2014

    @cowtowncoder
    Member

    @davideanderson I have noticed that it is better to try to respond quickly; otherwise it's easy to forget. And it's also self-reinforcing process, I appreciate when submitter follows up on issue too.

    Quick progress will halt for a bit (I'll be off for 20 day vacation now :) ), but hopefully we'll get this resolved in July. Thank you again for good suggestion; use case makes sense but I hadn't thought about it. One of those things that are obvious in hindsight.

  4. davideanderson commented on Jun 19, 2014

    @davideanderson
    Author

    Enjoy the vacation.. 20 days sounds great!

  5. cowtowncoder commented on Jul 10, 2015

    @cowtowncoder
    Member

    Just a quick note: have not been able to figure out how to do this yet, will not be part of 2.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions