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

Support for annotating enum values #798

Closed
m1h4 opened this issue May 20, 2015 · 2 comments
Closed

Support for annotating enum values #798

m1h4 opened this issue May 20, 2015 · 2 comments

Comments

@m1h4
Copy link

m1h4 commented May 20, 2015

Is there any reason why something like this would not be supported:

public enum DeviceType {
    @JsonPropertyValue("DeviceTypeMobile")
    DEVICE_TYPE_MOBILE,
    @JsonPropertyValue("DeviceTypeDesktop")
    DEVICE_TYPE_DESKTOP
}

and now when serialising/deserialising the values in the annotations would be used, but in Java you would use the more Java-like enum names.

Is there a technical issue preventing this from being supported or has no one simply addressed this yet?

I am aware of the more complicated, manual, way of achieving this behaviour using @JsonValue and @JsonCreator with custom from/to methods, but it seems this is enough of a common problem (at least for people that want neatly-named enum values) that the above, elegant, solution would be nice to have.

Would be interested in implementing this if need be

@m1h4
Copy link
Author

m1h4 commented May 20, 2015

I'm ashamed I did not look at past issues before posting, I now see that this exact feature was already discussed in January.

@cowtowncoder
Copy link
Member

Right, #677 is the original issue I think, so additional comments may be added there. And we should be able to just use @JsonProperty to reduce explosion in number of annotations declared.

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