Skip to content

Commit

Permalink
Merge remote-tracking branch 'FasterXML/2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Oct 13, 2024
2 parents 6ba21b1 + 6b374aa commit 7f5513f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ and those with secondary constructors or static factories are also supported.

# Status

* release `2.17.0` (for Jackson `2.17.x`) [![GitHub Actions build](https://github.com/FasterXML/jackson-module-kotlin/actions/workflows/main.yml/badge.svg?branch=2.16)](https://github.com/FasterXML/jackson-module-kotlin/actions?query=branch%3A2.17)
* release `2.18.0` (for Jackson `2.18.x`) [![GitHub Actions build](https://github.com/FasterXML/jackson-module-kotlin/actions/workflows/main.yml/badge.svg?branch=2.18)](https://github.com/FasterXML/jackson-module-kotlin/actions?query=branch%3A2.18)
* release `2.17.2` (for Jackson `2.17.x`) [![GitHub Actions build](https://github.com/FasterXML/jackson-module-kotlin/actions/workflows/main.yml/badge.svg?branch=2.17)](https://github.com/FasterXML/jackson-module-kotlin/actions?query=branch%3A2.17)
* release `2.16.2` (for Jackson `2.16.x`) [![GitHub Actions build](https://github.com/FasterXML/jackson-module-kotlin/actions/workflows/main.yml/badge.svg?branch=2.16)](https://github.com/FasterXML/jackson-module-kotlin/actions?query=branch%3A2.16)
* release `2.15.3` (for Jackson `2.15.x`) [![GitHub Actions build](https://github.com/FasterXML/jackson-module-kotlin/actions/workflows/main.yml/badge.svg?branch=2.15)](https://github.com/FasterXML/jackson-module-kotlin/actions?query=branch%3A2.15)
* release `2.15.4` (for Jackson `2.15.x`) [![GitHub Actions build](https://github.com/FasterXML/jackson-module-kotlin/actions/workflows/main.yml/badge.svg?branch=2.15)](https://github.com/FasterXML/jackson-module-kotlin/actions?query=branch%3A2.15)
* release `2.14.3` (for Jackson `2.14.x`) [![GitHub Actions build](https://github.com/FasterXML/jackson-module-kotlin/actions/workflows/main.yml/badge.svg?branch=2.14)](https://github.com/FasterXML/jackson-module-kotlin/actions?query=branch%3A2.14)

Releases require that you have included Kotlin stdlib and reflect libraries already.
Expand Down
8 changes: 7 additions & 1 deletion release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ Authors:

Contributors:

# 2.18.0 (not yet released)
# 2.19.0 (not yet released)

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

# 2.18.0 (26-Sep-2024)

WrongWrong (@k163377)
* #818: Optimize the search process for creators
Expand Down
3 changes: 2 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Co-maintainers:

2.19.0 (not yet released)

- No changes since 2.18
#839: Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName.
#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
12 changes: 7 additions & 5 deletions src/main/kotlin/tools/jackson/module/kotlin/KotlinModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tools.jackson.module.kotlin

import kotlin.reflect.KClass
import tools.jackson.databind.MapperFeature
import tools.jackson.databind.module.SimpleModule
import tools.jackson.module.kotlin.KotlinFeature.*
Expand All @@ -18,7 +17,10 @@ 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 enabledSingletonSupport Default: false. Whether to enable singleton handling.
* @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,
* the default, collections which are typed to disallow null members
* (e.g. List<String>) may contain null values after deserialization. Enabling it
Expand All @@ -33,15 +35,15 @@ class KotlinModule private constructor(
val nullToEmptyCollection: Boolean = NullToEmptyCollection.enabledByDefault,
val nullToEmptyMap: Boolean = NullToEmptyMap.enabledByDefault,
val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault,
val enabledSingletonSupport: Boolean = SingletonSupport.enabledByDefault,
val singletonSupport: Boolean = SingletonSupport.enabledByDefault,
val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault,
val kotlinPropertyNameAsImplicitName: Boolean = KotlinPropertyNameAsImplicitName.enabledByDefault,
val useJavaDurationConversion: Boolean = UseJavaDurationConversion.enabledByDefault,
) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) {

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

@Deprecated(
Expand Down Expand Up @@ -72,7 +74,7 @@ class KotlinModule private constructor(

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

if (enabledSingletonSupport) {
if (singletonSupport) {
// [module-kotlin#225]: keep Kotlin singletons as singletons
context.addDeserializerModifier(KotlinValueDeserializerModifier)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import kotlin.reflect.jvm.javaType

internal class KotlinNamesAnnotationIntrospector(
private val cache: ReflectionCache,
private val useKotlinPropertyNameForGetter: Boolean
private val kotlinPropertyNameAsImplicitName: Boolean
) : NopAnnotationIntrospector() {
private fun getterNameFromJava(member: AnnotatedMethod): String? {
val name = member.name
Expand Down Expand Up @@ -62,7 +62,7 @@ internal class KotlinNamesAnnotationIntrospector(

return when (member) {
is AnnotatedMethod -> if (member.parameterCount == 0) {
if (useKotlinPropertyNameForGetter) {
if (kotlinPropertyNameAsImplicitName) {
// Fall back to default if it is a getter-like function
getterNameFromKotlin(member) ?: getterNameFromJava(member)
} else getterNameFromJava(member)
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/tools/jackson/module/kotlin/DslTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DslTest {
assertTrue(module.nullToEmptyCollection)
assertTrue(module.nullToEmptyMap)
assertTrue(module.nullIsSameAsDefault)
assertTrue(module.enabledSingletonSupport)
assertTrue(module.singletonSupport)
assertTrue(module.strictNullChecks)
}

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

assertTrue(module.enabledSingletonSupport)
assertTrue(module.singletonSupport)
}

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

Expand Down

0 comments on commit 7f5513f

Please sign in to comment.