@@ -5,11 +5,11 @@ import com.fasterxml.jackson.databind.module.SimpleModule
5
5
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullIsSameAsDefault
6
6
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyCollection
7
7
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
8
+ import com.fasterxml.jackson.module.kotlin.KotlinFeature.SingletonSupport
8
9
import com.fasterxml.jackson.module.kotlin.KotlinFeature.StrictNullChecks
9
10
import com.fasterxml.jackson.module.kotlin.KotlinFeature.KotlinPropertyNameAsImplicitName
10
11
import com.fasterxml.jackson.module.kotlin.KotlinFeature.UseJavaDurationConversion
11
12
import java.util.*
12
- import kotlin.reflect.KClass
13
13
14
14
fun Class <* >.isKotlinClass (): Boolean = this .isAnnotationPresent(Metadata ::class .java)
15
15
@@ -23,8 +23,8 @@ fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class
23
23
* map object.
24
24
* @property nullIsSameAsDefault Default false. Whether to treat null values as absent when deserializing, thereby
25
25
* 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]
28
28
* @property enabledSingletonSupport Default: false. A temporary property that is maintained until the return value of `singletonSupport` is changed.
29
29
* It will be removed in 2.21.
30
30
* @property strictNullChecks Default: false. Whether to check deserialized collections. With this disabled,
@@ -41,13 +41,7 @@ class KotlinModule private constructor(
41
41
val nullToEmptyCollection : Boolean = NullToEmptyCollection .enabledByDefault,
42
42
val nullToEmptyMap : Boolean = NullToEmptyMap .enabledByDefault,
43
43
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,
51
45
val strictNullChecks : Boolean = StrictNullChecks .enabledByDefault,
52
46
@Deprecated(
53
47
level = DeprecationLevel .ERROR ,
@@ -60,12 +54,28 @@ class KotlinModule private constructor(
60
54
) : SimpleModule(KotlinModule : :class.java.name, PackageVersion .VERSION ) {
61
55
@Suppress(" DEPRECATION_ERROR" )
62
56
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
65
75
66
76
companion object {
67
77
// Increment when option is added
68
- private const val serialVersionUID = 2L
78
+ private const val serialVersionUID = 3L
69
79
}
70
80
71
81
@Deprecated(
@@ -79,11 +89,7 @@ class KotlinModule private constructor(
79
89
builder.isEnabled(NullToEmptyCollection ),
80
90
builder.isEnabled(NullToEmptyMap ),
81
91
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 ),
87
93
builder.isEnabled(StrictNullChecks ),
88
94
builder.isEnabled(KotlinPropertyNameAsImplicitName ),
89
95
builder.isEnabled(UseJavaDurationConversion ),
0 commit comments