@@ -5,11 +5,11 @@ import com.fasterxml.jackson.databind.module.SimpleModule
55import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullIsSameAsDefault
66import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyCollection
77import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
8+ import com.fasterxml.jackson.module.kotlin.KotlinFeature.SingletonSupport
89import com.fasterxml.jackson.module.kotlin.KotlinFeature.StrictNullChecks
910import com.fasterxml.jackson.module.kotlin.KotlinFeature.KotlinPropertyNameAsImplicitName
1011import com.fasterxml.jackson.module.kotlin.KotlinFeature.UseJavaDurationConversion
1112import java.util.*
12- import kotlin.reflect.KClass
1313
1414fun Class <* >.isKotlinClass (): Boolean = this .isAnnotationPresent(Metadata ::class .java)
1515
@@ -23,8 +23,8 @@ fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class
2323 * map object.
2424 * @property nullIsSameAsDefault Default false. Whether to treat null values as absent when deserializing, thereby
2525 * using the default value provided in Kotlin.
26- * @property singletonSupport Default: DISABLED . Mode for singleton handling.
27- * See {@link com.fasterxml.jackson.module.kotlin. SingletonSupport label}
26+ * @property singletonSupport Default: false . Mode for singleton handling.
27+ * See [KotlinFeature. SingletonSupport]
2828 * @property enabledSingletonSupport Default: false. A temporary property that is maintained until the return value of `singletonSupport` is changed.
2929 * It will be removed in 2.21.
3030 * @property strictNullChecks Default: false. Whether to check deserialized collections. With this disabled,
@@ -41,13 +41,7 @@ class KotlinModule private constructor(
4141 val nullToEmptyCollection : Boolean = NullToEmptyCollection .enabledByDefault,
4242 val nullToEmptyMap : Boolean = NullToEmptyMap .enabledByDefault,
4343 val nullIsSameAsDefault : Boolean = NullIsSameAsDefault .enabledByDefault,
44- @property:Deprecated(
45- level = DeprecationLevel .ERROR ,
46- message = "The return value will be Boolean in 2.19. Until then, use enabledSingletonSupport.",
47- replaceWith = ReplaceWith ("enabledSingletonSupport")
48- )
49- @Suppress(" DEPRECATION_ERROR" )
50- val singletonSupport : SingletonSupport = SingletonSupport .DISABLED ,
44+ val singletonSupport : Boolean = SingletonSupport .enabledByDefault,
5145 val strictNullChecks : Boolean = StrictNullChecks .enabledByDefault,
5246 @Deprecated(
5347 level = DeprecationLevel .ERROR ,
@@ -60,12 +54,28 @@ class KotlinModule private constructor(
6054) : SimpleModule(KotlinModule : :class.java.name, PackageVersion .VERSION ) {
6155 @Suppress(" DEPRECATION_ERROR" )
6256 val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter
63- @Suppress(" DEPRECATION_ERROR" )
64- val enabledSingletonSupport: Boolean get() = singletonSupport == SingletonSupport .CANONICALIZE
57+
58+ /*
59+ * Prior to 2.18, an older Enum called SingletonSupport was used to manage feature.
60+ * To deprecate it and replace it with singletonSupport: Boolean, the following steps are in progress.
61+ *
62+ * 1. add enabledSingletonSupport: Boolean property
63+ * 2. delete SingletonSupport class and change the property to singletonSupport: Boolean
64+ * 3. remove the enabledSingletonSupport property
65+ *
66+ * Now that 2 is complete, deprecation is in progress for 3.
67+ */
68+ @Deprecated(
69+ level = DeprecationLevel .WARNING ,
70+ message = " This property is scheduled to be removed in 2.21 or later" +
71+ " in order to unify the use of KotlinFeature." ,
72+ replaceWith = ReplaceWith (" singletonSupport" )
73+ )
74+ val enabledSingletonSupport: Boolean get() = singletonSupport
6575
6676 companion object {
6777 // Increment when option is added
68- private const val serialVersionUID = 2L
78+ private const val serialVersionUID = 3L
6979 }
7080
7181 @Deprecated(
@@ -79,11 +89,7 @@ class KotlinModule private constructor(
7989 builder.isEnabled(NullToEmptyCollection ),
8090 builder.isEnabled(NullToEmptyMap ),
8191 builder.isEnabled(NullIsSameAsDefault ),
82- @Suppress(" DEPRECATION_ERROR" )
83- when {
84- builder.isEnabled(KotlinFeature .SingletonSupport ) -> SingletonSupport .CANONICALIZE
85- else -> SingletonSupport .DISABLED
86- },
92+ builder.isEnabled(SingletonSupport ),
8793 builder.isEnabled(StrictNullChecks ),
8894 builder.isEnabled(KotlinPropertyNameAsImplicitName ),
8995 builder.isEnabled(UseJavaDurationConversion ),
0 commit comments