@@ -96,27 +96,20 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
96
96
return (this .annotations.firstOrNull { it.annotationClass.java == JsonProperty ::class .java } as ? JsonProperty )?.required
97
97
}
98
98
99
- private fun AnnotatedMethod.hasRequiredMarker (): Boolean? {
100
- // This could be a setter or a getter of a class property or
101
- // a setter-like/getter-like method.
102
- this .getFromCorrespondingAccessor()?.let { return it }
103
-
104
- // Is the member method a regular method of the data class or
105
- val method = this .member.kotlinFunction
106
- if (method != null ) {
99
+ // This could be a setter or a getter of a class property or
100
+ // a setter-like/getter-like method.
101
+ private fun AnnotatedMethod.hasRequiredMarker (): Boolean? = this .getFromCorrespondingAccessor()
102
+ ? : this .member.kotlinFunction?.let { method -> // Is the member method a regular method of the data class or
107
103
val byAnnotation = method.javaMethod?.isRequiredByAnnotation()
108
- if (method.isGetterLike()) {
109
- return requiredAnnotationOrNullability(byAnnotation, method.returnType.isRequired())
110
- }
111
-
112
- if ( method.isSetterLike()) {
113
- return requiredAnnotationOrNullability(byAnnotation, method.isMethodParameterRequired( 0 ))
104
+ when {
105
+ method.isGetterLike() ->
106
+ requiredAnnotationOrNullability(byAnnotation, method.returnType.isRequired())
107
+ method.isSetterLike() ->
108
+ requiredAnnotationOrNullability(byAnnotation, method.isMethodParameterRequired( 0 ))
109
+ else -> null
114
110
}
115
111
}
116
112
117
- return null
118
- }
119
-
120
113
private fun KFunction <* >.isGetterLike (): Boolean = parameters.size == 1
121
114
private fun KFunction <* >.isSetterLike (): Boolean =
122
115
parameters.size == 2 && returnType == Unit ::class .createType()
0 commit comments