Skip to content

Commit eb0ebae

Browse files
committed
kotlinize
1 parent db9352e commit eb0ebae

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,20 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
9696
return (this.annotations.firstOrNull { it.annotationClass.java == JsonProperty::class.java } as? JsonProperty)?.required
9797
}
9898

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
107103
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
114110
}
115111
}
116112

117-
return null
118-
}
119-
120113
private fun KFunction<*>.isGetterLike(): Boolean = parameters.size == 1
121114
private fun KFunction<*>.isSetterLike(): Boolean =
122115
parameters.size == 2 && returnType == Unit::class.createType()

0 commit comments

Comments
 (0)