Skip to content

Commit 28992a8

Browse files
authored
Merge pull request #782 from k163377/org-deps
Organize deprecated contents
2 parents 9c46588 + 39e0dfd commit 28992a8

File tree

7 files changed

+40
-203
lines changed

7 files changed

+40
-203
lines changed

pom.xml

+14-13
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
-->
225225
<!-- 30-Sep-2023, wrongwrong: For 2.16, compare to 2.15.2 baseline
226226
-->
227-
<version>2.16.0</version>
227+
<version>2.17.0</version>
228228
<type>jar</type>
229229
</dependency>
230230
</oldVersion>
@@ -239,19 +239,20 @@
239239
<excludes>
240240
<!-- public -->
241241
<!-- removed -->
242-
<exclude>com.fasterxml.jackson.module.kotlin.SequenceSerializer</exclude>
243-
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule#serialVersionUID</exclude>
242+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule#KotlinModule(int,boolean,boolean,boolean,com.fasterxml.jackson.module.kotlin.SingletonSupport,boolean,boolean,boolean)</exclude>
243+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullIsSameAsDefault()</exclude>
244+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullIsSameAsDefault(boolean)</exclude>
245+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullToEmptyCollection()</exclude>
246+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullToEmptyCollection(boolean)</exclude>
247+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullToEmptyMap()</exclude>
248+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullToEmptyMap(boolean)</exclude>
249+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getSingletonSupport()</exclude>
250+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#singletonSupport(com.fasterxml.jackson.module.kotlin.SingletonSupport)</exclude>
251+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getStrictNullChecks()</exclude>
252+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#strictNullChecks(boolean)</exclude>
253+
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#reflectionCacheSize(int)</exclude>
244254
<!-- internal -->
245-
<exclude>com.fasterxml.jackson.module.kotlin.KotlinNamesAnnotationIntrospector</exclude>
246-
<exclude>com.fasterxml.jackson.module.kotlin.ValueCreator</exclude>
247-
<exclude>com.fasterxml.jackson.module.kotlin.ConstructorValueCreator</exclude>
248-
<exclude>com.fasterxml.jackson.module.kotlin.MethodValueCreator</exclude>
249-
<exclude>com.fasterxml.jackson.module.kotlin.TypesKt</exclude>
250-
<exclude>com.fasterxml.jackson.module.kotlin.KotlinDeserializers</exclude>
251-
<exclude>com.fasterxml.jackson.module.kotlin.ExtensionsKt#isUnboxableValueClass(java.lang.Class)</exclude>
252-
<exclude>com.fasterxml.jackson.module.kotlin.ExtensionsKt#toBitSet(int)</exclude>
253-
<exclude>com.fasterxml.jackson.module.kotlin.ExtensionsKt#wrapWithPath(com.fasterxml.jackson.databind.JsonMappingException,java.lang.Object,java.lang.String)</exclude>
254-
<exclude>com.fasterxml.jackson.module.kotlin.ExtensionsKt#wrapWithPath(com.fasterxml.jackson.databind.JsonMappingException,java.lang.Object,int)</exclude>
255+
255256
</excludes>
256257
</parameter>
257258
</configuration>

release-notes/CREDITS-2.x

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Authors:
1515

1616
Contributors:
1717

18+
# 2.18.0 (not yet released)
19+
* #782: Organize deprecated contents
20+
1821
# 2.17.1 (not yet released)
1922

2023
WrongWrong (@k163377)

release-notes/VERSION-2.x

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ Co-maintainers:
1818

1919
2.18.0 (not yet released)
2020

21-
No changes since 2.17
21+
#782: Content marked as deprecated has been reorganized.
22+
Several constructors and accessors to properties of KotlinModule.Builder that were marked as DeprecationLevel.ERROR have been removed.
23+
Also, the content marked as DeprecationLevel.WARNING is now DeprecationLevel.ERROR.
2224

2325
2.17.1 (not yet released)
2426

src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt

+16-182
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
88
import com.fasterxml.jackson.module.kotlin.KotlinFeature.StrictNullChecks
99
import com.fasterxml.jackson.module.kotlin.KotlinFeature.KotlinPropertyNameAsImplicitName
1010
import com.fasterxml.jackson.module.kotlin.KotlinFeature.UseJavaDurationConversion
11-
import com.fasterxml.jackson.module.kotlin.SingletonSupport.CANONICALIZE
12-
import com.fasterxml.jackson.module.kotlin.SingletonSupport.DISABLED
1311
import java.util.*
1412
import kotlin.reflect.KClass
1513

1614
fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class.java)
1715

1816
/**
17+
* @constructor To avoid binary compatibility issues, the primary constructor is not published.
18+
* Please use KotlinModule.Builder or extensions that use it.
1919
* @property reflectionCacheSize Default: 512. Size, in items, of the caches used for mapping objects.
2020
* @property nullToEmptyCollection Default: false. Whether to deserialize null values for collection properties as
2121
* empty collections.
@@ -36,43 +36,32 @@ fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class
3636
* @property useJavaDurationConversion Default: false. Whether to use [java.time.Duration] as a bridge for [kotlin.time.Duration].
3737
* This allows use Kotlin Duration type with [com.fasterxml.jackson.datatype.jsr310.JavaTimeModule].
3838
*/
39-
class KotlinModule @Deprecated(
40-
level = DeprecationLevel.ERROR,
41-
message = "Use KotlinModule.Builder instead of named constructor parameters. It will be HIDDEN at 2.18.",
42-
replaceWith = ReplaceWith(
43-
"""KotlinModule.Builder()
44-
.withReflectionCacheSize(reflectionCacheSize)
45-
.configure(KotlinFeature.NullToEmptyCollection, nullToEmptyCollection)
46-
.configure(KotlinFeature.NullToEmptyMap, nullToEmptyMap)
47-
.configure(KotlinFeature.NullIsSameAsDefault, nullIsSameAsDefault)
48-
.configure(KotlinFeature.SingletonSupport, singletonSupport)
49-
.configure(KotlinFeature.StrictNullChecks, strictNullChecks)
50-
.build()""",
51-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
52-
)
53-
) constructor(
39+
class KotlinModule private constructor(
5440
val reflectionCacheSize: Int = Builder.DEFAULT_CACHE_SIZE,
5541
val nullToEmptyCollection: Boolean = NullToEmptyCollection.enabledByDefault,
5642
val nullToEmptyMap: Boolean = NullToEmptyMap.enabledByDefault,
5743
val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault,
5844
@property:Deprecated(
59-
level = DeprecationLevel.WARNING,
45+
level = DeprecationLevel.ERROR,
6046
message = "The return value will be Boolean in 2.19. Until then, use enabledSingletonSupport.",
6147
replaceWith = ReplaceWith("enabledSingletonSupport")
6248
)
63-
val singletonSupport: SingletonSupport = DISABLED,
49+
@Suppress("DEPRECATION_ERROR")
50+
val singletonSupport: SingletonSupport = SingletonSupport.DISABLED,
6451
val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault,
6552
@Deprecated(
66-
level = DeprecationLevel.WARNING,
53+
level = DeprecationLevel.ERROR,
6754
message = "There was a discrepancy between the property name and the Feature name." +
6855
" To migrate to the correct property name, it will be ERROR in 2.18 and removed in 2.19.",
6956
replaceWith = ReplaceWith("kotlinPropertyNameAsImplicitName")
7057
)
7158
val useKotlinPropertyNameForGetter: Boolean = KotlinPropertyNameAsImplicitName.enabledByDefault,
7259
val useJavaDurationConversion: Boolean = UseJavaDurationConversion.enabledByDefault,
7360
) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) {
61+
@Suppress("DEPRECATION_ERROR")
7462
val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter
75-
val enabledSingletonSupport: Boolean get() = singletonSupport == CANONICALIZE
63+
@Suppress("DEPRECATION_ERROR")
64+
val enabledSingletonSupport: Boolean get() = singletonSupport == SingletonSupport.CANONICALIZE
7665

7766
companion object {
7867
// Increment when option is added
@@ -83,45 +72,17 @@ class KotlinModule @Deprecated(
8372
level = DeprecationLevel.HIDDEN,
8473
message = "If you have no choice but to initialize KotlinModule from reflection, use this constructor."
8574
)
86-
@Suppress("DEPRECATION_ERROR")
8775
constructor() : this()
8876

89-
@Deprecated(level = DeprecationLevel.HIDDEN, message = "For ABI compatibility. It will be removed in 2.18.")
90-
constructor(
91-
reflectionCacheSize: Int,
92-
nullToEmptyCollection: Boolean,
93-
nullToEmptyMap: Boolean
94-
) : this(
95-
Builder()
96-
.withReflectionCacheSize(reflectionCacheSize)
97-
.configure(NullToEmptyCollection, nullToEmptyCollection)
98-
.configure(NullToEmptyMap, nullToEmptyMap)
99-
.disable(NullIsSameAsDefault)
100-
)
101-
102-
@Deprecated(level = DeprecationLevel.HIDDEN, message = "For ABI compatibility. It will be removed in 2.18.")
103-
constructor(
104-
reflectionCacheSize: Int,
105-
nullToEmptyCollection: Boolean,
106-
nullToEmptyMap: Boolean,
107-
nullIsSameAsDefault: Boolean
108-
) : this(
109-
Builder()
110-
.withReflectionCacheSize(reflectionCacheSize)
111-
.configure(NullToEmptyCollection, nullToEmptyCollection)
112-
.configure(NullToEmptyMap, nullToEmptyMap)
113-
.configure(NullIsSameAsDefault, nullIsSameAsDefault)
114-
)
115-
116-
@Suppress("DEPRECATION_ERROR")
11777
private constructor(builder: Builder) : this(
11878
builder.reflectionCacheSize,
11979
builder.isEnabled(NullToEmptyCollection),
12080
builder.isEnabled(NullToEmptyMap),
12181
builder.isEnabled(NullIsSameAsDefault),
82+
@Suppress("DEPRECATION_ERROR")
12283
when {
123-
builder.isEnabled(KotlinFeature.SingletonSupport) -> CANONICALIZE
124-
else -> DISABLED
84+
builder.isEnabled(KotlinFeature.SingletonSupport) -> SingletonSupport.CANONICALIZE
85+
else -> SingletonSupport.DISABLED
12586
},
12687
builder.isEnabled(StrictNullChecks),
12788
builder.isEnabled(KotlinPropertyNameAsImplicitName),
@@ -141,11 +102,8 @@ class KotlinModule @Deprecated(
141102

142103
context.addValueInstantiators(KotlinInstantiators(cache, nullToEmptyCollection, nullToEmptyMap, nullIsSameAsDefault, strictNullChecks))
143104

144-
when (singletonSupport) {
145-
DISABLED -> Unit
146-
CANONICALIZE -> {
147-
context.addBeanDeserializerModifier(KotlinBeanDeserializerModifier)
148-
}
105+
if (enabledSingletonSupport) {
106+
context.addBeanDeserializerModifier(KotlinBeanDeserializerModifier)
149107
}
150108

151109
context.insertAnnotationIntrospector(KotlinAnnotationIntrospector(
@@ -160,7 +118,7 @@ class KotlinModule @Deprecated(
160118
KotlinNamesAnnotationIntrospector(
161119
cache,
162120
ignoredClassesForImplyingJsonCreator,
163-
useKotlinPropertyNameForGetter)
121+
kotlinPropertyNameAsImplicitName)
164122
)
165123

166124
context.addDeserializers(KotlinDeserializers(cache, useJavaDurationConversion))
@@ -203,130 +161,6 @@ class KotlinModule @Deprecated(
203161
fun isEnabled(feature: KotlinFeature): Boolean =
204162
bitSet.intersects(feature.bitSet)
205163

206-
@Deprecated(
207-
level = DeprecationLevel.ERROR,
208-
message = "Deprecated, use withReflectionCacheSize(reflectionCacheSize) instead. It will be removed in 2.18.",
209-
replaceWith = ReplaceWith("withReflectionCacheSize(reflectionCacheSize)")
210-
)
211-
fun reflectionCacheSize(reflectionCacheSize: Int): Builder =
212-
withReflectionCacheSize(reflectionCacheSize)
213-
214-
@Deprecated(
215-
level = DeprecationLevel.ERROR,
216-
message = "Deprecated, use isEnabled(NullToEmptyCollection) instead. It will be removed in 2.18.",
217-
replaceWith = ReplaceWith(
218-
"isEnabled(KotlinFeature.NullToEmptyCollection)",
219-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
220-
)
221-
)
222-
fun getNullToEmptyCollection(): Boolean =
223-
isEnabled(NullToEmptyCollection)
224-
225-
@Deprecated(
226-
level = DeprecationLevel.ERROR,
227-
message = "Deprecated, use configure(NullToEmptyCollection, enabled) instead. It will be removed in 2.18.",
228-
replaceWith = ReplaceWith(
229-
"configure(KotlinFeature.NullToEmptyCollection, nullToEmptyCollection)",
230-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
231-
)
232-
)
233-
fun nullToEmptyCollection(nullToEmptyCollection: Boolean): Builder =
234-
configure(NullToEmptyCollection, nullToEmptyCollection)
235-
236-
@Deprecated(
237-
level = DeprecationLevel.ERROR,
238-
message = "Deprecated, use isEnabled(NullToEmptyMap) instead. It will be removed in 2.18.",
239-
replaceWith = ReplaceWith(
240-
"isEnabled(KotlinFeature.NullToEmptyMap)",
241-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
242-
)
243-
)
244-
fun getNullToEmptyMap(): Boolean =
245-
isEnabled(NullToEmptyMap)
246-
247-
@Deprecated(
248-
level = DeprecationLevel.ERROR,
249-
message = "Deprecated, use configure(NullToEmptyMap, enabled) instead. It will be removed in 2.18.",
250-
replaceWith = ReplaceWith(
251-
"configure(KotlinFeature.NullToEmptyMap, nullToEmptyMap)",
252-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
253-
)
254-
)
255-
fun nullToEmptyMap(nullToEmptyMap: Boolean): Builder =
256-
configure(NullToEmptyMap, nullToEmptyMap)
257-
258-
@Deprecated(
259-
level = DeprecationLevel.ERROR,
260-
message = "Deprecated, use isEnabled(NullIsSameAsDefault) instead. It will be removed in 2.18.",
261-
replaceWith = ReplaceWith(
262-
"isEnabled(KotlinFeature.NullIsSameAsDefault)",
263-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
264-
)
265-
)
266-
fun getNullIsSameAsDefault(): Boolean =
267-
isEnabled(NullIsSameAsDefault)
268-
269-
@Deprecated(
270-
level = DeprecationLevel.ERROR,
271-
message = "Deprecated, use configure(NullIsSameAsDefault, enabled) instead. It will be removed in 2.18.",
272-
replaceWith = ReplaceWith(
273-
"configure(KotlinFeature.NullIsSameAsDefault, nullIsSameAsDefault)",
274-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
275-
)
276-
)
277-
fun nullIsSameAsDefault(nullIsSameAsDefault: Boolean): Builder =
278-
configure(NullIsSameAsDefault, nullIsSameAsDefault)
279-
280-
@Deprecated(
281-
level = DeprecationLevel.ERROR,
282-
message = "Deprecated, use isEnabled(SingletonSupport) instead. It will be removed in 2.18.",
283-
replaceWith = ReplaceWith(
284-
"isEnabled(KotlinFeature.SingletonSupport)",
285-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
286-
)
287-
)
288-
fun getSingletonSupport(): SingletonSupport =
289-
when {
290-
isEnabled(KotlinFeature.SingletonSupport) -> CANONICALIZE
291-
else -> DISABLED
292-
}
293-
294-
@Deprecated(
295-
level = DeprecationLevel.ERROR,
296-
message = "Deprecated, use configure(SingletonSupport, enabled) instead. It will be removed in 2.18.",
297-
replaceWith = ReplaceWith(
298-
"configure(KotlinFeature.SingletonSupport, singletonSupport)",
299-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
300-
)
301-
)
302-
fun singletonSupport(singletonSupport: SingletonSupport): Builder =
303-
when (singletonSupport) {
304-
CANONICALIZE -> enable(KotlinFeature.SingletonSupport)
305-
else -> disable(KotlinFeature.SingletonSupport)
306-
}
307-
308-
@Deprecated(
309-
level = DeprecationLevel.ERROR,
310-
message = "Deprecated, use isEnabled(StrictNullChecks) instead. It will be removed in 2.18.",
311-
replaceWith = ReplaceWith(
312-
"isEnabled(KotlinFeature.StrictNullChecks)",
313-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
314-
)
315-
)
316-
fun getStrictNullChecks(): Boolean =
317-
isEnabled(StrictNullChecks)
318-
319-
@Deprecated(
320-
level = DeprecationLevel.ERROR,
321-
message = "Deprecated, use configure(StrictNullChecks, enabled) instead. It will be removed in 2.18.",
322-
replaceWith = ReplaceWith(
323-
"configure(KotlinFeature.StrictNullChecks, strictNullChecks)",
324-
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
325-
)
326-
)
327-
fun strictNullChecks(strictNullChecks: Boolean): Builder =
328-
configure(StrictNullChecks, strictNullChecks)
329-
330164
fun build(): KotlinModule =
331165
KotlinModule(this)
332166
}

src/main/kotlin/com/fasterxml/jackson/module/kotlin/SingletonSupport.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package com.fasterxml.jackson.module.kotlin
44
* Special handling for singletons.
55
*/
66
@Deprecated(
7-
level = DeprecationLevel.WARNING,
7+
level = DeprecationLevel.ERROR,
88
message = "It will be removed in 2.19 to unify with KotlinFeature.",
99
replaceWith = ReplaceWith("KotlinFeature.SingletonSupport")
1010
)

src/test/kotlin/com/fasterxml/jackson/module/kotlin/DslTest.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyCollection
77
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
88
import com.fasterxml.jackson.module.kotlin.KotlinFeature.SingletonSupport
99
import com.fasterxml.jackson.module.kotlin.KotlinFeature.StrictNullChecks
10-
import com.fasterxml.jackson.module.kotlin.SingletonSupport.CANONICALIZE
1110
import org.junit.Assert.assertNotNull
1211
import org.junit.Test
1312
import kotlin.test.assertEquals
@@ -44,7 +43,7 @@ class DslTest {
4443
assertTrue(module.nullToEmptyCollection)
4544
assertTrue(module.nullToEmptyMap)
4645
assertTrue(module.nullIsSameAsDefault)
47-
assertEquals(module.singletonSupport, CANONICALIZE)
46+
assertTrue(module.enabledSingletonSupport)
4847
assertTrue(module.strictNullChecks)
4948
}
5049

src/test/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModuleTest.kt

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class KotlinModuleTest {
1717
assertFalse(module.nullToEmptyCollection)
1818
assertFalse(module.nullToEmptyMap)
1919
assertFalse(module.nullIsSameAsDefault)
20-
assertEquals(SingletonSupport.DISABLED, module.singletonSupport)
2120
assertFalse(module.enabledSingletonSupport)
2221
assertFalse(module.strictNullChecks)
2322
assertFalse(module.kotlinPropertyNameAsImplicitName)
@@ -41,7 +40,6 @@ class KotlinModuleTest {
4140
assertTrue(module.nullToEmptyCollection)
4241
assertTrue(module.nullToEmptyMap)
4342
assertTrue(module.nullIsSameAsDefault)
44-
assertEquals(SingletonSupport.CANONICALIZE, module.singletonSupport)
4543
assertTrue(module.enabledSingletonSupport)
4644
assertTrue(module.strictNullChecks)
4745
assertTrue(module.kotlinPropertyNameAsImplicitName)
@@ -81,7 +79,7 @@ class KotlinModuleTest {
8179
enable(SingletonSupport)
8280
}.build()
8381

84-
assertEquals(SingletonSupport.CANONICALIZE, module.singletonSupport)
82+
assertTrue(module.enabledSingletonSupport)
8583
}
8684

8785
@Test
@@ -112,7 +110,7 @@ class KotlinModuleTest {
112110
assertTrue(deserialized.nullToEmptyCollection)
113111
assertTrue(deserialized.nullToEmptyMap)
114112
assertTrue(deserialized.nullIsSameAsDefault)
115-
assertEquals(SingletonSupport.CANONICALIZE, deserialized.singletonSupport)
113+
assertTrue(deserialized.enabledSingletonSupport)
116114
assertTrue(deserialized.strictNullChecks)
117115
}
118116

0 commit comments

Comments
 (0)