Change to an early return
MODIFY
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt
@@ -63,10 +63,17 @@ internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val c
.apply { if (this in ignoredClassesForImplyingJsonCreator) return false }
val kConstructor = cache.kotlinFromJava(member.annotated as Constructor<Any>) ?: return false
- val isPrimaryConstructor = kClass.isPrimaryConstructor(kConstructor)
+ // TODO: should we do this check or not? It could cause failures if we miss another way a property could be set
+ // val requiredProperties = kClass.declaredMemberProperties.filter {!it.returnType.isMarkedNullable }.map { it.name }.toSet()
+ // val areAllRequiredParametersInConstructor = kConstructor.parameters.all { requiredProperties.contains(it.name) }
val propertyNames = kClass.memberProperties.map { it.name }.toSet()
+ return when {
+ kConstructor.isPossibleSingleString(propertyNames) -> false
+ kConstructor.parameters.any { it.name == null } -> false
+ !kClass.isPrimaryConstructor(kConstructor) -> false
+ else -> {
val anyConstructorHasJsonCreator = kClass.constructors
.filterOutSingleStringCallables(propertyNames)
.any { it.hasAnnotation<JsonCreator>() }
@@ -76,18 +83,9 @@ internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val c
?.any { it.hasAnnotation<JsonCreator>() && it.hasAnnotation<JvmStatic>() }
?: false
- // TODO: should we do this check or not? It could cause failures if we miss another way a property could be set
- // val requiredProperties = kClass.declaredMemberProperties.filter {!it.returnType.isMarkedNullable }.map { it.name }.toSet()
- // val areAllRequiredParametersInConstructor = kConstructor.parameters.all { requiredProperties.contains(it.name) }
-
- val areAllParametersValid = kConstructor.parameters.all { it.name != null }
-
- val isSingleStringConstructor = kConstructor.isPossibleSingleString(propertyNames)
-
- return isPrimaryConstructor
- && !(anyConstructorHasJsonCreator || anyCompanionMethodIsJsonCreator)
- && areAllParametersValid
- && !isSingleStringConstructor
+ !(anyConstructorHasJsonCreator || anyCompanionMethodIsJsonCreator)
+ }
+ }
}
override fun hasCreatorAnnotation(member: Annotated): Boolean =

Change to an early return