FasterXML / FasterXML/jackson-module-scala

See if there is benefit from integrating with jackson-databind better wrt detecting "canonical" Constructor for Scala (case) classes

オープン
#677 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Scala
スター
506
フォーク
138
平均マージ
3時間 6分
マージ済み PR(30日)
48

説明

With 2.18 jackson-databind has a new, rewritten logic for POJO Property detection: work was done mostly under https://github.com/FasterXML/jackson-databind/issues/4515.

Logic, at high-level, selects at most one "Properties-based" Creator (constructor / static factory method), in following order:

1. Explicitly annotated (either `@JsonCreator` on ctor/factory, or at least one parameter of ctor/factory annotated with `@JsonProperty`)
2. Canonical -- currently only detected for Record types
3. Implicit Constructor: if all parameters of a constructor have implicit names, is visible (by default: public) and there is only one such choice (not even 0-args "default" constructor)

This works for many cases. But JVM languages like Scala (and Kotlin) typically have their own definition of canonical constructor, so it'd be good to allow pluggable handling.
(in plain Java we only have Records with the concept of specific canonical (primary) constructor, over alternatives that are also visible)

My initial idea would be to add one (ideally) new method in `AnnotationIntrospector`, which would take 2 sets of candidates -- Constructors and Factory Methods (`PotentialCreator`) -- that might qualify; and result would be zero or one of passed-in choices to indicate Canonical, Properties-based creator to use, if any.
Method would only be called if no explicit choice were found.

I am not sure if similar functionality should be available to allow implicit Delegating Creator: possibly?
If so, it would be given 2 sets of potential candidates, as well as previously chosen Properties-based creator, if any. But I am not yet sure that is needed.

Would the first part make sense, @pjfanning, from Scala module perspective?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。