Cut out a large process into a function
MODIFY
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt
@@ -56,15 +56,13 @@ internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val c
}
@Suppress("UNCHECKED_CAST")
- override fun hasCreatorAnnotation(member: Annotated): Boolean {
+ private fun hasCreatorAnnotation(member: AnnotatedConstructor): Boolean {
// don't add a JsonCreator to any constructor if one is declared already
- return if (member is AnnotatedConstructor && member.isKotlinConstructorWithParameters()) {
- cache.checkConstructorIsCreatorAnnotated(member) {
val kClass = cache.kotlinFromJava(member.declaringClass as Class<Any>)
val kConstructor = cache.kotlinFromJava(member.annotated as Constructor<Any>)
- if (kConstructor != null) {
+ return if (kConstructor != null) {
val isPrimaryConstructor = kClass.primaryConstructor == kConstructor ||
(kClass.primaryConstructor == null && kClass.constructors.size == 1)
@@ -96,8 +94,12 @@ internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val c
false
}
}
- } else false
- }
+
+ override fun hasCreatorAnnotation(member: Annotated): Boolean =
+ if (member is AnnotatedConstructor && member.isKotlinConstructorWithParameters())
+ cache.checkConstructorIsCreatorAnnotated(member) { hasCreatorAnnotation(it) }
+ else
+ false
@Suppress("UNCHECKED_CAST")
private fun findKotlinParameterName(param: AnnotatedParameter): String? {

Cut out a large process into a function