diff --git a/pom.xml b/pom.xml index 043ebdb8..4671fb04 100644 --- a/pom.xml +++ b/pom.xml @@ -239,6 +239,9 @@ + + com.fasterxml.jackson.module.kotlin.KotlinModule#getUseKotlinPropertyNameForGetter() + com.fasterxml.jackson.module.kotlin.KotlinModule#getSingletonSupport() com.fasterxml.jackson.module.kotlin.SingletonSupport diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index c378593f..18ad194b 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -18,6 +18,7 @@ Contributors: # 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) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 1ae9cf7e..1df0b782 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -18,6 +18,7 @@ Co-maintainers: 2.19.0 (not yet released) +#839: Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName. #835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport. 2.18.0 (26-Sep-2024) diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt index 843c65ab..d396324d 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt @@ -43,18 +43,9 @@ class KotlinModule private constructor( val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault, val singletonSupport: Boolean = SingletonSupport.enabledByDefault, val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault, - @Deprecated( - 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 kotlinPropertyNameAsImplicitName: Boolean = KotlinPropertyNameAsImplicitName.enabledByDefault, val useJavaDurationConversion: Boolean = UseJavaDurationConversion.enabledByDefault, ) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) { - @Suppress("DEPRECATION_ERROR") - val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter - /* * 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. diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt index 0eb1e8ac..6489ed03 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt @@ -1,12 +1,10 @@ package com.fasterxml.jackson.module.kotlin -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.JavaType import com.fasterxml.jackson.databind.cfg.MapperConfig import com.fasterxml.jackson.databind.introspect.Annotated import com.fasterxml.jackson.databind.introspect.AnnotatedClass -import com.fasterxml.jackson.databind.introspect.AnnotatedConstructor import com.fasterxml.jackson.databind.introspect.AnnotatedMember import com.fasterxml.jackson.databind.introspect.AnnotatedMethod import com.fasterxml.jackson.databind.introspect.AnnotatedParameter @@ -16,18 +14,15 @@ import java.lang.reflect.Constructor import java.util.Locale import kotlin.reflect.KClass import kotlin.reflect.KFunction -import kotlin.reflect.full.companionObject -import kotlin.reflect.full.declaredFunctions import kotlin.reflect.full.hasAnnotation import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor -import kotlin.reflect.jvm.javaConstructor import kotlin.reflect.jvm.javaGetter 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 @@ -67,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)