-
Notifications
You must be signed in to change notification settings - Fork 77
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
android-record: Support deserializing polymorphic members of records #249
Conversation
Thank you. LGTM. @cowtowncoder, your thougths? |
First of all, thank you @HelloOO7 ! Correct, context is passed via Code looks ok, although somehow it feels like this should be doable via Now: I really want to go through this in more detail, then merge, but am leaving for a vacation today. But will pick this up once I return in 2 weeks. |
…r (not ValueInstantiator)
I expanded upon ValueInstantiator in effort to adhere to the spirit of the original implementation. I may be wrong here, but wouldn't using JsonDeserializer needlessly couple the Android record module to the JSON format? Upon looking into this further, I came up with a more similar-to-JDK approach to Android records that uses an AnnotationIntrospector, see here: https://github.com/HelloOO7/jackson-modules-base/tree/android-records-2 if (_isRecordType) {
primary = JDK14Util.findCanonicalRecordConstructor(_config, _classDef, constructors);
} else {
primary = _annotationIntrospector.findDefaultCreator(_config, _classDef,
constructors, factories);
} However, this fails the |
I added included test in core Will try to get this reviewed now. |
No, despite its name, |
@HelloOO7 I like the looks of the alternate take -- could you do a PR for that instead, and I can get it quickly reviewed? And yes, now that I looked at the original implementation it makes sense that you extended |
Sure. Would it be okay to merge the new commits to the main branch of my fork and update this PR, or should I submit a new one? |
@HelloOO7 Either way is fine, whatever is easiest to do? |
Alright, I merged it to my branch of 2.18. It's now awaiting review as part of this PR as far as I can see (commit has appeared before my last message probably 'cause it's sorted chronologically). |
I reckon I should probably update the tests to no longer be in the failing package, if this approch is the way to go forward. |
Hmmmh. I wish indentation was not changed -- merging this into |
Thank you @HelloOO7 -- now merged in 2.18 for 2.18.0 as well as |
Oh well. I tried to configure it to keep 2 spaces indentation (which I think it did), but the tests had strangely nested static classes on a different indentation level than static methods, which my IDE couldn't keep up with:( Sorry. |
I'm really looking forward to have this fixed in 2.18. It's gonna be nice not to have to bother with workarounds. Thank you too! |
@HelloOO7 yeah np, indentation gets tricky no worries. Glad to have gotten it all merged. |
This fixes #248 (see tests). As far as I could tell, the non-default ValueInstantiators do not have access to a DeserializationContext when created, so there's a fair bit of redundancy in place when using
createContextual
instead.