Skip to content

Commit ee7ec66

Browse files
committed
Refactor
Functionalize the use decision of NullsAsEmptyProvider
1 parent 1ddf63f commit ee7ec66

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/deser/value_instantiator/KotlinValueInstantiator.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.fasterxml.jackson.module.kotlin.deser.value_instantiator
33
import com.fasterxml.jackson.databind.BeanDescription
44
import com.fasterxml.jackson.databind.DeserializationConfig
55
import com.fasterxml.jackson.databind.DeserializationContext
6+
import com.fasterxml.jackson.databind.JavaType
67
import com.fasterxml.jackson.databind.deser.SettableBeanProperty
78
import com.fasterxml.jackson.databind.deser.ValueInstantiator
89
import com.fasterxml.jackson.databind.deser.ValueInstantiators
@@ -28,6 +29,9 @@ internal class KotlinValueInstantiator(
2829
// @see com.fasterxml.jackson.module.kotlin._ported.test.StrictNullChecksTest#testListOfGenericWithNullValue
2930
private fun ValueParameter.isNullishTypeAt(index: Int) = arguments.getOrNull(index)?.isNullable ?: true
3031

32+
private fun JavaType.requireEmptyValue() =
33+
(nullToEmptyCollection && this.isCollectionLikeType) || (nullToEmptyMap && this.isMapLikeType)
34+
3135
private fun strictNullCheck(
3236
ctxt: DeserializationContext,
3337
jsonProp: SettableBeanProperty,
@@ -87,7 +91,7 @@ internal class KotlinValueInstantiator(
8791
}
8892
}
8993

90-
if (paramVal == null && ((nullToEmptyCollection && jsonProp.type.isCollectionLikeType) || (nullToEmptyMap && jsonProp.type.isMapLikeType))) {
94+
if (paramVal == null && jsonProp.type.requireEmptyValue()) {
9195
paramVal = NullsAsEmptyProvider(jsonProp.valueDeserializer).getNullValue(ctxt)
9296
}
9397

0 commit comments

Comments
 (0)