JsonAdapter.nonNull() forbids explicit nulls in the JSON body

This adapter modifier throws exceptions if an unexpected null is
encountered. This may pair nicely with Kotlin.
This commit is contained in:
Jesse Wilson
2018-04-04 23:08:36 -07:00
parent ad69a4f495
commit 466f77aabe
3 changed files with 73 additions and 1 deletions

View File

@@ -196,7 +196,7 @@ class JsonClassCodeGenProcessor : KotlinAbstractProcessor(), KotlinMetadataUtils
val hasDefault = parameter?.declaresDefaultValue ?: true
if (enclosedElement.modifiers.contains(Modifier.TRANSIENT)) {
if (Modifier.TRANSIENT in enclosedElement.modifiers) {
if (!hasDefault) {
throw IllegalArgumentException("No default value for transient property $name")
}