@@ -33,31 +33,35 @@ internal class KotlinNamesAnnotationIntrospector(
33
33
val ignoredClassesForImplyingJsonCreator : Set <KClass <* >>,
34
34
val useKotlinPropertyNameForGetter : Boolean
35
35
) : NopAnnotationIntrospector() {
36
+ private fun getterNameFromJava (member : AnnotatedMember ): String? {
37
+ val name = member.name
38
+
39
+ // The reason for truncating after `-` is to truncate the random suffix
40
+ // given after the value class accessor name.
41
+ return when {
42
+ name.startsWith(" get" ) -> name.takeIf { it.contains(" -" ) }?.let { _ ->
43
+ name.substringAfter(" get" )
44
+ .replaceFirstChar { it.lowercase(Locale .getDefault()) }
45
+ .substringBefore(' -' )
46
+ }
47
+ // since 2.15: support Kotlin's way of handling "isXxx" backed properties where
48
+ // logical property name needs to remain "isXxx" and not become "xxx" as with Java Beans
49
+ // (see https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html and
50
+ // https://github.com/FasterXML/jackson-databind/issues/2527 and
51
+ // https://github.com/FasterXML/jackson-module-kotlin/issues/340
52
+ // for details)
53
+ name.startsWith(" is" ) -> if (name.contains(" -" )) name.substringAfter(" -" ) else name
54
+ else -> null
55
+ }
56
+ }
57
+
36
58
// since 2.4
37
59
override fun findImplicitPropertyName (member : AnnotatedMember ): String? {
38
60
if (! member.declaringClass.isKotlinClass()) return null
39
61
40
- val name = member.name
41
-
42
62
return when (member) {
43
63
is AnnotatedMethod -> if (member.parameterCount == 0 ) {
44
- // The reason for truncating after `-` is to truncate the random suffix
45
- // given after the value class accessor name.
46
- when {
47
- name.startsWith(" get" ) -> name.takeIf { it.contains(" -" ) }?.let { _ ->
48
- name.substringAfter(" get" )
49
- .replaceFirstChar { it.lowercase(Locale .getDefault()) }
50
- .substringBefore(' -' )
51
- }
52
- // since 2.15: support Kotlin's way of handling "isXxx" backed properties where
53
- // logical property name needs to remain "isXxx" and not become "xxx" as with Java Beans
54
- // (see https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html and
55
- // https://github.com/FasterXML/jackson-databind/issues/2527 and
56
- // https://github.com/FasterXML/jackson-module-kotlin/issues/340
57
- // for details)
58
- name.startsWith(" is" ) -> if (name.contains(" -" )) name.substringAfter(" -" ) else name
59
- else -> null
60
- }
64
+ if (useKotlinPropertyNameForGetter) TODO () else getterNameFromJava(member)
61
65
} else null
62
66
is AnnotatedParameter -> findKotlinParameterName(member)
63
67
else -> null
0 commit comments