Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Bundled' @JsonView annotations should merge #38

Open
davideanderson opened this issue Jun 18, 2014 · 5 comments
Open

'Bundled' @JsonView annotations should merge #38

davideanderson opened this issue Jun 18, 2014 · 5 comments

Comments

@davideanderson
Copy link

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.

@cowtowncoder
Copy link
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).

@davideanderson
Copy link
Author

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

@cowtowncoder
Copy link
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.

@davideanderson
Copy link
Author

Enjoy the vacation.. 20 days sounds great!

@cowtowncoder
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants