-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Handle Enum introspection of values and aliases via AnnotatedClass instead of Class<?>
#3832
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
Merged
cowtowncoder
merged 55 commits into
FasterXML:2.16
from
JooHyukKim:2787-allow-mixins-for-enums
Jun 16, 2023
Merged
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
0ff49d2
Add test cases
JooHyukKim d9b70a9
Allow construction of EnumResolver for mixin class
JooHyukKim b11db13
Remove Pojo example tests
JooHyukKim fbcc1c3
improve JavaDoc
JooHyukKim 3ebe045
Clean up tests
JooHyukKim 4cdef6c
Fix failing test
JooHyukKim bcd9025
Add test for mix-in of Wrapper field
JooHyukKim ed21cf3
Fix documentation
JooHyukKim e33619e
Implement JacksonAnnotationIntrospector
JooHyukKim 39ff50d
Merge branch '2787-allow-mixins-for-enums' of https://github.com/JooH…
JooHyukKim 51f923b
Merge branch '2787-allow-mixins-for-enums' of https://github.com/JooH…
JooHyukKim 1f7bbc1
Remove mixin from EnumResolver
JooHyukKim 9478871
Update BasicDeserializerFactory.java
JooHyukKim 2a80825
Add MapperConfig as first parameter
JooHyukKim b9a0677
Filter self referencing properties with JsonFormat.Shape is `OBJECT`
JooHyukKim 05d77bb
Add more description
JooHyukKim ac04e46
Merge branch '2.15' into 2787-allow-mixins-for-enums
JooHyukKim caac7f5
Remove unused import
JooHyukKim b8447f7
Merge branch '2787-allow-mixins-for-enums' of https://github.com/JooH…
JooHyukKim 89d80de
Update EnumResolver.java
JooHyukKim 4440da0
Tidy up comments and control flow
JooHyukKim e132e9d
Merge remote-tracking branch 'upstream/2.15' into 2787-allow-mixins-f…
JooHyukKim 244a871
Simplify method signatures (apply reviews)
JooHyukKim baa9c8c
Merge branch '2.15' into 2787-allow-mixins-for-enums
JooHyukKim 5143724
Move removing self-referencing enum fields
JooHyukKim ad73809
Merge remote-tracking branch 'upstream/2.15' into 2787-allow-mixins-f…
JooHyukKim a20d61d
Clean up EnumResolver
JooHyukKim d3a57ee
Clean up JacksonAnnotationIntrospector
JooHyukKim 872dd10
Update EnumResolver.java
JooHyukKim 8ae8ff4
Implement JacksonAnnotationIntrospector
JooHyukKim e89a778
Merge branch '2787-allow-mixins-for-enums' of https://github.com/JooH…
JooHyukKim abbee55
Allow construction of EnumResolver for mixin class
JooHyukKim d4d56e2
improve JavaDoc
JooHyukKim c07dd2f
Fix documentation
JooHyukKim 47788f0
Remove mixin from EnumResolver
JooHyukKim 99cf1f7
Add MapperConfig as first parameter
JooHyukKim 0669e3c
Filter self referencing properties with JsonFormat.Shape is `OBJECT`
JooHyukKim 1bd982a
Add more description
JooHyukKim 833f6c4
Remove unused import
JooHyukKim dca4506
Update EnumResolver.java
JooHyukKim e3f7b1b
Tidy up comments and control flow
JooHyukKim ac2af2b
Simplify method signatures (apply reviews)
JooHyukKim aa589e5
Move removing self-referencing enum fields
JooHyukKim 50570b9
Clean up JacksonAnnotationIntrospector
JooHyukKim f91657c
Clean up changes
JooHyukKim c78a0e4
Merge branch '2787-allow-mixins-for-enums' of https://github.com/JooH…
JooHyukKim 5d98b69
Update EnumResolver.java
JooHyukKim 5a85d0b
Merge remote-tracking branch 'upstream/2.16' into 2787-allow-mixins-f…
JooHyukKim 3b89923
Modify JavaDoc
JooHyukKim db48e04
Squashed commit of the following:
JooHyukKim 6bbf646
Revert "Squashed commit of the following:"
JooHyukKim f68e42b
Merge branch 'FasterXML:2.16' into 2787-allow-mixins-for-enums
JooHyukKim 24f3f45
Merge remote-tracking branch 'upstream/2.16' into 2787-allow-mixins-f…
JooHyukKim 1f5baf6
Apply review, improve `JacksonAnnotationIntropector` implementation l…
JooHyukKim 426fef5
Improve JavaDoc wrt #2787
JooHyukKim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1209,6 +1209,10 @@ protected JsonSerializer<?> buildEnumSerializer(SerializationConfig config, | |
| if (format.getShape() == JsonFormat.Shape.OBJECT) { | ||
| // one special case: suppress serialization of "getDeclaringClass()"... | ||
| ((BasicBeanDescription) beanDesc).removeProperty("declaringClass"); | ||
| // [databind#2787]: remove self-referencing enum fields introduced by annotation flattening of mixins | ||
| if (type.isEnumType()){ | ||
| _removeEnumSelfReferences(((BasicBeanDescription) beanDesc)); | ||
| } | ||
| // returning null will mean that eventually BeanSerializer gets constructed | ||
| return null; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where |
||
|
|
@@ -1224,6 +1228,30 @@ protected JsonSerializer<?> buildEnumSerializer(SerializationConfig config, | |
| return ser; | ||
| } | ||
|
|
||
| /** | ||
| * Helper method used for serialization {@link Enum} as {@link JsonFormat.Shape#OBJECT}. Removes any | ||
| * self-referencing properties from its bean description before it is transformed into a JSON Object | ||
| * as configured by {@link JsonFormat.Shape#OBJECT}. | ||
| * <p> | ||
| * Internally, this method iterates through {@link BeanDescription#findProperties()} and removes self. | ||
| * | ||
| * @param beanDesc the bean description to remove Enum properties from. | ||
| * | ||
| * @since 2.16 | ||
| */ | ||
| private void _removeEnumSelfReferences(BasicBeanDescription beanDesc) { | ||
| Class<?> aClass = ClassUtil.findEnumType(beanDesc.getBeanClass()); | ||
| Iterator<BeanPropertyDefinition> it = beanDesc.findProperties().iterator(); | ||
| while (it.hasNext()) { | ||
| BeanPropertyDefinition property = it.next(); | ||
| JavaType propType = property.getPrimaryType(); | ||
| // is the property a self-reference? | ||
| if (propType.isEnumType() && propType.isTypeOrSubTypeOf(aClass)) { | ||
| it.remove(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| /********************************************************** | ||
| /* Other helper methods | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.