Skip to content

Commit 750c8a9

Browse files
committed
Refactor
Streamlining decisions
1 parent ee7ec66 commit 750c8a9

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,25 @@ internal class KotlinValueInstantiator(
9191
}
9292
}
9393

94-
if (paramVal == null && jsonProp.type.requireEmptyValue()) {
95-
paramVal = NullsAsEmptyProvider(jsonProp.valueDeserializer).getNullValue(ctxt)
96-
}
97-
98-
val isMissingAndRequired = paramVal == null && isMissing && jsonProp.isRequired
99-
if (isMissingAndRequired || (!paramDef.isGenericType && paramVal == null && !paramDef.isNullable)) {
100-
throw MissingKotlinParameterException(
101-
parameter = paramDef,
102-
processor = ctxt.parser,
103-
msg = "Instantiation of ${this.valueTypeDesc} value failed for JSON property ${jsonProp.name} due to missing (therefore NULL) value for creator parameter ${paramDef.name} which is a non-nullable type"
104-
).wrapWithPath(this.valueClass, jsonProp.name)
94+
if (paramVal == null) {
95+
if (jsonProp.type.requireEmptyValue()) {
96+
paramVal = NullsAsEmptyProvider(jsonProp.valueDeserializer).getNullValue(ctxt)
97+
} else {
98+
val isMissingAndRequired = isMissing && jsonProp.isRequired
99+
if (isMissingAndRequired || (!paramDef.isGenericType && !paramDef.isNullable)) {
100+
throw MissingKotlinParameterException(
101+
parameter = paramDef,
102+
processor = ctxt.parser,
103+
msg = "Instantiation of $valueTypeDesc value failed for JSON property ${jsonProp.name} " +
104+
"due to missing (therefore NULL) value for creator parameter ${paramDef.name} " +
105+
"which is a non-nullable type"
106+
).wrapWithPath(this.valueClass, jsonProp.name)
107+
}
108+
}
109+
} else {
110+
if (strictNullChecks) strictNullCheck(ctxt, jsonProp, paramDef, paramVal)
105111
}
106112

107-
if (strictNullChecks && paramVal != null) strictNullCheck(ctxt, jsonProp, paramDef, paramVal)
108-
109113
bucket[idx] = paramVal
110114
}
111115

0 commit comments

Comments
 (0)