mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 16:39:22 +08:00
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:
@@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user