-
Notifications
You must be signed in to change notification settings - Fork 6k
generated enums #1919
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
Comments
There is an easy fix for this. First, the enum generation in the templates should be updated as such:
Note the Next, the Serialization mapper--if Jackson--should be configured as such:
With this change, the @wing328 I can make this change but for the other libraries (gson, for example), we may need to have a different approach. |
@fehguy this is noted. We'll test other Java HTTP libraries. |
@fehguy I would write this fromValue method slightly differently: @JsonCreator
public static MixedCase fromValue(String text) {
for (MixedCase b : MixedCase.values()) {
if (b.text.equals(text)) {
return b;
}
}
return null;
} No need for the null check, other possibly for a performance optimization. |
@ePaul I like your suggestion. Do you have cycle to contribute the enhancement? |
@wing328 I can't promise anything currently, sorry. (I'm on vacations until start of April, and then likely will be buried in project work again.) |
@ePaul enjoy your vacation! We'll take care of it. No worry. |
Added via #3531 |
Currently a generated class gives enums like such:
When constructing a value from the string "enum 1", you will get an error as "enum 1" is compared against the ENUM1 and ENUM2 keys, resulting in an exception.
The text was updated successfully, but these errors were encountered: