Skip to content

Commit 3fb8a29

Browse files
committed
Fixed to ignore nullToEmpty option in fields and setters
Because nullToEmpty options do not work for these at now.
1 parent 84cb9e3 commit 3fb8a29

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/main/kotlin/io/github/projectmapk/jackson/module/kogera/annotationIntrospector/KotlinPrimaryAnnotationIntrospector.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ internal class KotlinPrimaryAnnotationIntrospector(
5959
private fun JavaType.hasDefaultEmptyValue() = (nullToEmptyCollection && isCollectionLikeType) ||
6060
(nullToEmptyMap && isMapLikeType)
6161

62-
// The nullToEmpty option also affects serialization,
63-
// but deserialization is preferred because there is currently no way to distinguish between contexts.
6462
private fun AnnotatedField.hasRequiredMarker(jmClass: JmClass): Boolean? {
6563
// Direct access to `AnnotatedField` is only performed if there is no accessor (defined as JvmField),
6664
// so if an accessor is defined, it is ignored.
@@ -69,7 +67,7 @@ internal class KotlinPrimaryAnnotationIntrospector(
6967
// only a check for the existence of a getter is performed.
7068
// https://youtrack.jetbrains.com/issue/KT-6519
7169
?.let {
72-
if (it.getterName == null) !(it.returnType.isNullable || type.hasDefaultEmptyValue()) else null
70+
if (it.getterName == null) !it.returnType.isNullable else null
7371
}
7472
}
7573

@@ -80,12 +78,8 @@ internal class KotlinPrimaryAnnotationIntrospector(
8078
): Boolean? = when (parameterCount) {
8179
0 -> jmClass.findPropertyByGetter(member)?.isRequiredByNullability()
8280
1 -> {
83-
if (this.getParameter(0).type.hasDefaultEmptyValue()) {
84-
false
85-
} else {
86-
val memberSignature = member.toSignature()
87-
jmClass.properties.find { it.setterSignature == memberSignature }?.isRequiredByNullability()
88-
}
81+
val memberSignature = member.toSignature()
82+
jmClass.properties.find { it.setterSignature == memberSignature }?.isRequiredByNullability()
8983
}
9084
else -> null
9185
}

0 commit comments

Comments
 (0)