-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Use @JsonProperty
and lowercase feature when serializing Enums despite write using toString()
#4039
Use @JsonProperty
and lowercase feature when serializing Enums despite write using toString()
#4039
Conversation
…MS_USING_TO_STRING
@JooHyukKim Could you also review this PR please? |
src/main/java/com/fasterxml/jackson/databind/util/EnumValues.java
Outdated
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java
Outdated
Show resolved
Hide resolved
* | ||
* @since 2.16 | ||
*/ | ||
protected final EnumValues _valuesByToString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not confident about readability perspective, but is it possible to use the same/similar structure as other EnumValues
members' javadoc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the review - can you elaborate on what you mean here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally thought it will be easier to read if javadoc of _values
, _valuesByEnumNaming
, and _valuesByToString
had similarly structured paragraph and use similar terms. But can skip my comment, thanks 👍🏻
src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java
Outdated
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Kim, Joo Hyuk <beanskobe@gmail.com>
@@ -82,6 +92,20 @@ public EnumSerializer(EnumValues v, Boolean serializeAsIndex, EnumValues valuesB | |||
_values = v; | |||
_serializeAsIndex = serializeAsIndex; | |||
_valuesByEnumNaming = valuesByEnumNaming; | |||
_valuesByToString = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should just use this(v, serializeAsIndex, valuesByEnumNaming, null)
; ?
Also let's add @Deprecated
(and Javadoc) here
@@ -71,6 +80,7 @@ public EnumSerializer(EnumValues v, Boolean serializeAsIndex) | |||
_values = v; | |||
_serializeAsIndex = serializeAsIndex; | |||
_valuesByEnumNaming = null; | |||
_valuesByToString = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just delegate (with this(v, serializeAsIndex, null, null)
).
Also, unless called from non-deprecated code, let's also mark as @Deprecated
// since 2.16.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; just need to add some more Deprecation markers & could chain from deprecated constructors.
Actually, I can do these post-merge, so approving & merging now.
@JsonProperty
and lowercase feature when serializing Enums despite write using toString
@JsonProperty
and lowercase feature when serializing Enums despite write using toString@JsonProperty
and lowercase feature when serializing Enums despite write using toString()
Serialization complement of #4036