Skip to content

Commit

Permalink
Merge pull request #835 from k163377/fix-dep
Browse files Browse the repository at this point in the history
Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport
  • Loading branch information
k163377 authored Oct 13, 2024
2 parents 25a3cee + 68b605d commit 0c52167
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 76 deletions.
40 changes: 3 additions & 37 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
-->
<!-- 30-Sep-2023, wrongwrong: For 2.16, compare to 2.15.2 baseline
-->
<version>2.17.0</version>
<version>2.18.0</version>
<type>jar</type>
</dependency>
</oldVersion>
Expand All @@ -239,43 +239,9 @@
<excludes>
<!-- public -->
<!-- removed -->
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinModule#KotlinModule(int,boolean,boolean,boolean,com.fasterxml.jackson.module.kotlin.SingletonSupport,boolean,boolean,boolean)
</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullIsSameAsDefault()
</exclude>
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullIsSameAsDefault(boolean)
</exclude>
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullToEmptyCollection()
</exclude>
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullToEmptyCollection(boolean)
</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullToEmptyMap()
</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullToEmptyMap(boolean)
</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getSingletonSupport()
</exclude>
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#singletonSupport(com.fasterxml.jackson.module.kotlin.SingletonSupport)
</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getStrictNullChecks()
</exclude>
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#strictNullChecks(boolean)
</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#reflectionCacheSize(int)
</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule#getSingletonSupport()</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.SingletonSupport</exclude>
<!-- internal -->
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinNamesAnnotationIntrospector#KotlinNamesAnnotationIntrospector(com.fasterxml.jackson.module.kotlin.ReflectionCache,java.util.Set,boolean)
</exclude>
<exclude>
com.fasterxml.jackson.module.kotlin.ReflectionCache#checkConstructorIsCreatorAnnotated(com.fasterxml.jackson.databind.introspect.AnnotatedConstructor,kotlin.jvm.functions.Function1)
</exclude>

</excludes>
</parameter>
Expand Down
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Authors:

Contributors:

# 2.19.0 (not yet released)

WrongWrong (@k163377)
* #835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport

# 2.18.0 (26-Sep-2024)

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

2.19.0 (not yet released)

- No changes since 2.18
#835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport.

2.18.0 (26-Sep-2024)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ enum class KotlinFeature(internal val enabledByDefault: Boolean) {
* Deserializing a singleton overwrites the value of the single instance.
*
* See [jackson-module-kotlin#225]: keep Kotlin singletons as singletons.
* @see com.fasterxml.jackson.module.kotlin.SingletonSupport
*/
SingletonSupport(enabledByDefault = false),

Expand Down
42 changes: 24 additions & 18 deletions src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullIsSameAsDefault
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyCollection
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
import com.fasterxml.jackson.module.kotlin.KotlinFeature.SingletonSupport
import com.fasterxml.jackson.module.kotlin.KotlinFeature.StrictNullChecks
import com.fasterxml.jackson.module.kotlin.KotlinFeature.KotlinPropertyNameAsImplicitName
import com.fasterxml.jackson.module.kotlin.KotlinFeature.UseJavaDurationConversion
import java.util.*
import kotlin.reflect.KClass

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

Expand All @@ -23,8 +23,8 @@ fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class
* map object.
* @property nullIsSameAsDefault Default false. Whether to treat null values as absent when deserializing, thereby
* using the default value provided in Kotlin.
* @property singletonSupport Default: DISABLED. Mode for singleton handling.
* See {@link com.fasterxml.jackson.module.kotlin.SingletonSupport label}
* @property singletonSupport Default: false. Mode for singleton handling.
* See [KotlinFeature.SingletonSupport]
* @property enabledSingletonSupport Default: false. A temporary property that is maintained until the return value of `singletonSupport` is changed.
* It will be removed in 2.21.
* @property strictNullChecks Default: false. Whether to check deserialized collections. With this disabled,
Expand All @@ -41,13 +41,7 @@ class KotlinModule private constructor(
val nullToEmptyCollection: Boolean = NullToEmptyCollection.enabledByDefault,
val nullToEmptyMap: Boolean = NullToEmptyMap.enabledByDefault,
val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault,
@property:Deprecated(
level = DeprecationLevel.ERROR,
message = "The return value will be Boolean in 2.19. Until then, use enabledSingletonSupport.",
replaceWith = ReplaceWith("enabledSingletonSupport")
)
@Suppress("DEPRECATION_ERROR")
val singletonSupport: SingletonSupport = SingletonSupport.DISABLED,
val singletonSupport: Boolean = SingletonSupport.enabledByDefault,
val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault,
@Deprecated(
level = DeprecationLevel.ERROR,
Expand All @@ -60,12 +54,28 @@ class KotlinModule private constructor(
) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) {
@Suppress("DEPRECATION_ERROR")
val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter
@Suppress("DEPRECATION_ERROR")
val enabledSingletonSupport: Boolean get() = singletonSupport == SingletonSupport.CANONICALIZE

/*
* Prior to 2.18, an older Enum called SingletonSupport was used to manage feature.
* To deprecate it and replace it with singletonSupport: Boolean, the following steps are in progress.
*
* 1. add enabledSingletonSupport: Boolean property
* 2. delete SingletonSupport class and change the property to singletonSupport: Boolean
* 3. remove the enabledSingletonSupport property
*
* Now that 2 is complete, deprecation is in progress for 3.
*/
@Deprecated(
level = DeprecationLevel.WARNING,
message = "This property is scheduled to be removed in 2.21 or later" +
" in order to unify the use of KotlinFeature.",
replaceWith = ReplaceWith("singletonSupport")
)
val enabledSingletonSupport: Boolean get() = singletonSupport

companion object {
// Increment when option is added
private const val serialVersionUID = 2L
private const val serialVersionUID = 3L
}

@Deprecated(
Expand All @@ -79,11 +89,7 @@ class KotlinModule private constructor(
builder.isEnabled(NullToEmptyCollection),
builder.isEnabled(NullToEmptyMap),
builder.isEnabled(NullIsSameAsDefault),
@Suppress("DEPRECATION_ERROR")
when {
builder.isEnabled(KotlinFeature.SingletonSupport) -> SingletonSupport.CANONICALIZE
else -> SingletonSupport.DISABLED
},
builder.isEnabled(SingletonSupport),
builder.isEnabled(StrictNullChecks),
builder.isEnabled(KotlinPropertyNameAsImplicitName),
builder.isEnabled(UseJavaDurationConversion),
Expand Down

This file was deleted.

0 comments on commit 0c52167

Please sign in to comment.