-
-
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
Record class support for ObjectMapper#updateValue #3079
Comments
Sounds reasonable, and agreed, copy-if-cannot-update is conceptually expected. One thing that would help a bit would be to create a small unit test to show expected behavior, just to verify the fix. It's not a ton of work to create by whoever works on this, but could help a little still; and would also work as verification of the fix. |
Sigh. Testing Record feature from Java 8 baseline is a royal PITA, partly due to having to pass "enable-review" flag on some JDKs (14 and 15) and ABSOLUTELY MUSTING NOT TO DO SO for others (16). And "--" being illegal in XML comments so commenting out in pom.xml no-go as well. But I am able to reproduce this. Need to figure out how to indicate that "POJO" deserializer for Record shall not be applied in case of underlying |
Note to self: while in theory we could try:
that would not work for root values which simply try calling Which at first seems fine except that now it would also need to access existing values, somehow, to merge. And in fact same is true for both paths since it is not possible to just create an empty instance anyway: values of existing properties are needed. |
Starting to think that we actually should create separate Or, possibly, make |
An alternative:
Caveat:
|
A similar problem was reported for |
@yihtserns while users can use Another thought: while we could attempt to access field values via canonical accessors, there might be problems with potential annotation-based renaming (or So on short term I don't see this as being plausible to implement. |
Just realized something important: although full Not sure how practical this would be to implement, but at least it would be feasible. |
If I understand correctly, |
@JooHyukKim Not necessarily, no. This is cross-cutting concern and if databind handled using of getter-method/field to access information, it should work with Kotlin and Scala modules too (unless they override some aspects etc), without requiring additional work. |
updateValue
is a convenient way to update the fields of a POJO and it even supports changing hierarchical values.Currently when the object to be updated is an instance of a Record class it throws an exception, rightfully because the fields of the record are immutable:
Would it be feasible for the
updateValue
to support Record classes in such a way that it would not update the object in place, but instead it would return a new object with the updated values?For example:
Based on its signature this behavior is already in place for arrays.
The text was updated successfully, but these errors were encountered: