Skip to content

Commit

Permalink
Merge remote-tracking branch 'FasterXML/2.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Apr 5, 2024
2 parents 242f480 + 28992a8 commit 82c12a3
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 44 deletions.
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,21 @@
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
<breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
<excludes>
<!-- public -->
<!-- removed -->
<exclude>com.fasterxml.jackson.module.kotlin.SequenceSerializer</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule#serialVersionUID</exclude>
<!-- internal -->
<exclude>com.fasterxml.jackson.module.kotlin.KotlinNamesAnnotationIntrospector</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.ValueCreator</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.ConstructorValueCreator</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.MethodValueCreator</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.TypesKt</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinDeserializers</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.ExtensionsKt#isUnboxableValueClass(java.lang.Class)</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.ExtensionsKt#toBitSet(int)</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.ExtensionsKt#wrapWithPath(com.fasterxml.jackson.databind.JsonMappingException,java.lang.Object,java.lang.String)</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.ExtensionsKt#wrapWithPath(com.fasterxml.jackson.databind.JsonMappingException,java.lang.Object,int)</exclude>
</excludes>
</parameter>
</configuration>
Expand Down
3 changes: 3 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Authors:

Contributors:

# 2.18.0 (not yet released)
* #782: Organize deprecated contents

# 2.17.1 (not yet released)

WrongWrong (@k163377)
Expand Down
4 changes: 3 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Co-maintainers:

2.18.0 (not yet released)

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

2.17.1 (not yet released)

Expand Down
49 changes: 13 additions & 36 deletions src/main/kotlin/tools/jackson/module/kotlin/KotlinModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import java.util.*
fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class.java)

/**
* @constructor To avoid binary compatibility issues, the primary constructor is not published.
* Please use KotlinModule.Builder or extensions that use it.
* @property reflectionCacheSize Default: 512. Size, in items, of the caches used for mapping objects.
* @property nullToEmptyCollection Default: false. Whether to deserialize null values for collection properties as
* empty collections.
Expand Down Expand Up @@ -51,23 +53,26 @@ class KotlinModule @Deprecated(
val nullToEmptyMap: Boolean = NullToEmptyMap.enabledByDefault,
val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault,
@property:Deprecated(
level = DeprecationLevel.WARNING,
level = DeprecationLevel.ERROR,
message = "The return value will be Boolean in 2.19. Until then, use enabledSingletonSupport.",
replaceWith = ReplaceWith("enabledSingletonSupport")
)
val singletonSupport: SingletonSupport = DISABLED,
@Suppress("DEPRECATION_ERROR")
val singletonSupport: SingletonSupport = SingletonSupport.DISABLED,
val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault,
@Deprecated(
level = DeprecationLevel.WARNING,
level = DeprecationLevel.ERROR,
message = "There was a discrepancy between the property name and the Feature name." +
" To migrate to the correct property name, it will be ERROR in 2.18 and removed in 2.19.",
replaceWith = ReplaceWith("kotlinPropertyNameAsImplicitName")
)
val useKotlinPropertyNameForGetter: Boolean = KotlinPropertyNameAsImplicitName.enabledByDefault,
val useJavaDurationConversion: Boolean = UseJavaDurationConversion.enabledByDefault,
) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) {
@Suppress("DEPRECATION_ERROR")
val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter
val enabledSingletonSupport: Boolean get() = singletonSupport == CANONICALIZE
@Suppress("DEPRECATION_ERROR")
val enabledSingletonSupport: Boolean get() = singletonSupport == SingletonSupport.CANONICALIZE

companion object {
// Increment when option is added
Expand All @@ -78,45 +83,17 @@ class KotlinModule @Deprecated(
level = DeprecationLevel.HIDDEN,
message = "If you have no choice but to initialize KotlinModule from reflection, use this constructor."
)
@Suppress("DEPRECATION_ERROR")
constructor() : this()

@Deprecated(level = DeprecationLevel.HIDDEN, message = "For ABI compatibility. It will be removed in 2.18.")
constructor(
reflectionCacheSize: Int,
nullToEmptyCollection: Boolean,
nullToEmptyMap: Boolean
) : this(
Builder()
.withReflectionCacheSize(reflectionCacheSize)
.configure(NullToEmptyCollection, nullToEmptyCollection)
.configure(NullToEmptyMap, nullToEmptyMap)
.disable(NullIsSameAsDefault)
)

@Deprecated(level = DeprecationLevel.HIDDEN, message = "For ABI compatibility. It will be removed in 2.18.")
constructor(
reflectionCacheSize: Int,
nullToEmptyCollection: Boolean,
nullToEmptyMap: Boolean,
nullIsSameAsDefault: Boolean
) : this(
Builder()
.withReflectionCacheSize(reflectionCacheSize)
.configure(NullToEmptyCollection, nullToEmptyCollection)
.configure(NullToEmptyMap, nullToEmptyMap)
.configure(NullIsSameAsDefault, nullIsSameAsDefault)
)

@Suppress("DEPRECATION_ERROR")
private constructor(builder: Builder) : this(
builder.reflectionCacheSize,
builder.isEnabled(NullToEmptyCollection),
builder.isEnabled(NullToEmptyMap),
builder.isEnabled(NullIsSameAsDefault),
@Suppress("DEPRECATION_ERROR")
when {
builder.isEnabled(KotlinFeature.SingletonSupport) -> CANONICALIZE
else -> DISABLED
builder.isEnabled(KotlinFeature.SingletonSupport) -> SingletonSupport.CANONICALIZE
else -> SingletonSupport.DISABLED
},
builder.isEnabled(StrictNullChecks),
builder.isEnabled(KotlinPropertyNameAsImplicitName),
Expand Down Expand Up @@ -156,7 +133,7 @@ class KotlinModule @Deprecated(
KotlinNamesAnnotationIntrospector(
cache,
ignoredClassesForImplyingJsonCreator,
useKotlinPropertyNameForGetter)
kotlinPropertyNameAsImplicitName)
)

context.addDeserializers(KotlinDeserializers(cache, useJavaDurationConversion))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package tools.jackson.module.kotlin
* Special handling for singletons.
*/
@Deprecated(
level = DeprecationLevel.WARNING,
level = DeprecationLevel.ERROR,
message = "It will be removed in 2.19 to unify with KotlinFeature.",
replaceWith = ReplaceWith("KotlinFeature.SingletonSupport")
)
Expand Down
3 changes: 1 addition & 2 deletions src/test/kotlin/tools/jackson/module/kotlin/DslTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import tools.jackson.module.kotlin.KotlinFeature.NullToEmptyCollection
import tools.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
import tools.jackson.module.kotlin.KotlinFeature.SingletonSupport
import tools.jackson.module.kotlin.KotlinFeature.StrictNullChecks
import tools.jackson.module.kotlin.SingletonSupport.CANONICALIZE
import org.junit.Assert.assertNotNull
import org.junit.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -44,7 +43,7 @@ class DslTest {
assertTrue(module.nullToEmptyCollection)
assertTrue(module.nullToEmptyMap)
assertTrue(module.nullIsSameAsDefault)
assertEquals(module.singletonSupport, CANONICALIZE)
assertTrue(module.enabledSingletonSupport)
assertTrue(module.strictNullChecks)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class KotlinModuleTest {
assertFalse(module.nullToEmptyCollection)
assertFalse(module.nullToEmptyMap)
assertFalse(module.nullIsSameAsDefault)
assertEquals(SingletonSupport.DISABLED, module.singletonSupport)
assertFalse(module.enabledSingletonSupport)
assertFalse(module.strictNullChecks)
assertFalse(module.kotlinPropertyNameAsImplicitName)
Expand All @@ -41,7 +40,6 @@ class KotlinModuleTest {
assertTrue(module.nullToEmptyCollection)
assertTrue(module.nullToEmptyMap)
assertTrue(module.nullIsSameAsDefault)
assertEquals(SingletonSupport.CANONICALIZE, module.singletonSupport)
assertTrue(module.enabledSingletonSupport)
assertTrue(module.strictNullChecks)
assertTrue(module.kotlinPropertyNameAsImplicitName)
Expand Down Expand Up @@ -81,7 +79,7 @@ class KotlinModuleTest {
enable(SingletonSupport)
}.build()

assertEquals(SingletonSupport.CANONICALIZE, module.singletonSupport)
assertTrue(module.enabledSingletonSupport)
}

@Test
Expand Down Expand Up @@ -112,7 +110,7 @@ class KotlinModuleTest {
assertTrue(deserialized.nullToEmptyCollection)
assertTrue(deserialized.nullToEmptyMap)
assertTrue(deserialized.nullIsSameAsDefault)
assertEquals(SingletonSupport.CANONICALIZE, deserialized.singletonSupport)
assertTrue(deserialized.enabledSingletonSupport)
assertTrue(deserialized.strictNullChecks)
}

Expand Down

0 comments on commit 82c12a3

Please sign in to comment.