Skip to content

Commit 87b6217

Browse files
committed
split to method
1 parent a2419db commit 87b6217

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinAnnotationIntrospector.kt

+11-10
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,7 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
9999
// This could be a setter or a getter of a class property or
100100
// a setter-like/getter-like method.
101101
private fun AnnotatedMethod.hasRequiredMarker(): Boolean? = this.getRequiredMarkerFromCorrespondingAccessor()
102-
?: this.member.kotlinFunction?.let { method -> // Is the member method a regular method of the data class or
103-
val byAnnotation = method.javaMethod?.isRequiredByAnnotation()
104-
when {
105-
method.isGetterLike() ->
106-
requiredAnnotationOrNullability(byAnnotation, method.returnType.isRequired())
107-
method.isSetterLike() ->
108-
requiredAnnotationOrNullability(byAnnotation, method.isMethodParameterRequired(0))
109-
else -> null
110-
}
111-
}
102+
?: this.member.kotlinFunction?.getRequiredMarkerFromAccessorLikeMethod()
112103

113104
private fun AnnotatedMethod.getRequiredMarkerFromCorrespondingAccessor(): Boolean? {
114105
member.declaringClass.kotlin.declaredMemberProperties.forEach { kProperty1 ->
@@ -129,6 +120,16 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
129120
return null
130121
}
131122

123+
// Is the member method a regular method of the data class or
124+
private fun KFunction<*>.getRequiredMarkerFromAccessorLikeMethod(): Boolean? {
125+
val byAnnotation = this.javaMethod?.isRequiredByAnnotation()
126+
return when {
127+
this.isGetterLike() -> requiredAnnotationOrNullability(byAnnotation, this.returnType.isRequired())
128+
this.isSetterLike() -> requiredAnnotationOrNullability(byAnnotation, this.isMethodParameterRequired(0))
129+
else -> null
130+
}
131+
}
132+
132133
private fun KFunction<*>.isGetterLike(): Boolean = parameters.size == 1
133134
private fun KFunction<*>.isSetterLike(): Boolean =
134135
parameters.size == 2 && returnType == Unit::class.createType()

0 commit comments

Comments
 (0)