Skip to content

Commit

Permalink
Merge pull request #839 from k163377/fix-dep3
Browse files Browse the repository at this point in the history
Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName
  • Loading branch information
k163377 authored Oct 13, 2024
2 parents 8c971d0 + d47100e commit 6b374aa
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@
<excludes>
<!-- public -->
<!-- removed -->
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinModule#getUseKotlinPropertyNameForGetter()
</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule#getSingletonSupport()</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.SingletonSupport</exclude>
<!-- internal -->
Expand Down
1 change: 1 addition & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6b374aa

Please sign in to comment.