Skip to content

Commit

Permalink
Nix null checks in favor of serializeNulls
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Feb 19, 2018
1 parent 8eb5bb4 commit dea9c0b
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,22 +626,14 @@ private data class Adapter(
.addStatement("%N.beginObject()", writer)
.apply {
propertyList.forEachIndexed { index, prop ->
if (prop.nullable) {
beginControlFlow("if (%N${if (index == 0) "!!" else ""}.%L != null)",
value,
prop.name)
}
addStatement("%N.name(%S)",
writer,
prop.serializedName)
addStatement("%N.toJson(%N, %N${if (index == 0 && !prop.nullable) "!!" else ""}.%L)",
addStatement("%N.toJson(%N, %N${if (index == 0) "!!" else ""}.%L)",
adapterProperties[prop.typeName to prop.jsonQualifiers]!!,
writer,
value,
prop.name)
if (prop.nullable) {
endControlFlow()
}
}
}
.addStatement("%N.endObject()", writer)
Expand Down

0 comments on commit dea9c0b

Please sign in to comment.