-
-
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 key type factory methods ahead of ctors #2180
Use key type factory methods ahead of ctors #2180
Conversation
What is the basis for change? Is this the order used for values too? |
Fixes FasterXML#2158 Simply swaps the order factory method and String constructors are searched for in the key type. Factory methods are now preferred.
d6a1b6d
to
07aca04
Compare
That I had this PR going completely slipped my mind. Rebased it now that the unrelated issue I was hitting is merged and it now builds and tests cleanly. |
In answer to your question "Is this the order for values too?" - yes, where a single field constructor is present and not itself annotated with If single argument constructor of the same type is present and annotated with
|
Ok thanks -- I will need to re-read this, and will put it on my todo list. |
Thanks Tatu!
[cid:67BA6677-8CED-46CB-910D-CFCFBF6C063E@gateway]
On 19 Jul 2019, at 9:47 am, Tatu Saloranta <[email protected]<mailto:[email protected]>> wrote:
Ok thanks -- I will need to re-read this, and will put it on my todo list.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#2180?email_source=notifications&email_token=AAZQNHGWGSAZDVCO46PQ5PTQAD6IHA5CNFSM4GCI46O2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2KEXSI#issuecomment-513035209>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAZQNHAKIR3UAAWNDJHNV53QAD6IHANCNFSM4GCI46OQ>.
|
Hmm. Ok. This gets tricky. So, // Important: first add factory methods; then constructors, so
// latter can override former!
_addDeserializerFactoryMethods(ctxt, beanDesc, vchecker, intr, creators, creatorDefs);
if (beanDesc.getType().isConcrete()) {
_addDeserializerConstructors(ctxt, beanDesc, vchecker, intr, creators, creatorDefs);
} which would suggest constructors are (or were intended) to have precedence over factory methods. And as far as I can tell, conflicts only matter with explicit (annotated conflicts) -- in case of implicitly found creators, later ones override earlier ones. Given this, I don't think I want to change the lookup order: existing order has been default order since now so there need to be some really good reason to change it. However. One thing I could add would be to check for explicit annotation (
|
Fixes #2158
Simply swaps the order factory method and String
constructors are searched for in the key type.
Factory methods are now preferred.