Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dynamic invocation
// Code generated by moshi-kotlin-codegen. Do not edit.
package com.squareup.moshi.kotlin.codgen
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.squareup.moshi.internal.Util
import java.lang.NullPointerException
import java.lang.StringBuilder
import java.lang.reflect.Constructor
import kotlin.Any
import kotlin.Array
import kotlin.Boolean
import kotlin.Float
import kotlin.Int
import kotlin.IntArray
import kotlin.String
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.collections.MutableList
import kotlin.collections.Set
import kotlin.collections.emptySet
import kotlin.jvm.Volatile
class SmokeTestTypeJsonAdapter(moshi: Moshi) : JsonAdapter<SmokeTestType>() {
private val options: JsonReader.Options = JsonReader.Options.of("first_name", "last_name",
"age", "nationalities", "weight", "tattoos", "race", "hasChildren", "favoriteFood",
"favoriteDrink", "wildcardOut", "nullableWildcardOut", "wildcardIn", "any", "anyTwo",
"anyOut", "nullableAnyOut", "favoriteThreeNumbers", "favoriteArrayValues",
"favoriteNullableArrayValues", "nullableSetListMapArrayNullableIntWithDefault",
"aliasedName", "genericAlias")
@Volatile
private var constructorRef: Constructor<SmokeTestType>? = null
private val stringAdapter: JsonAdapter<String> = moshi.adapter<String>(String::class.java,
emptySet(), "firstName")
private val intAdapter: JsonAdapter<Int> = moshi.adapter<Int>(Int::class.java, emptySet(),
"age")
private val listOfStringAdapter: JsonAdapter<List<String>> =
moshi.adapter<List<String>>(Types.newParameterizedType(List::class.java,
String::class.java), emptySet(), "nationalities")
private val floatAdapter: JsonAdapter<Float> = moshi.adapter<Float>(Float::class.java,
emptySet(), "weight")
private val booleanAdapter: JsonAdapter<Boolean> = moshi.adapter<Boolean>(Boolean::class.java,
emptySet(), "tattoos")
private val nullableStringAdapter: JsonAdapter<String?> =
moshi.adapter<String?>(String::class.java, emptySet(), "race")
private val mutableListOfStringAdapter: JsonAdapter<MutableList<out String>> =
moshi.adapter<MutableList<out
String>>(Types.newParameterizedType(MutableList::class.java,
Types.subtypeOf(String::class.java)), emptySet(), "wildcardOut")
private val mutableListOfNullableStringAdapter: JsonAdapter<MutableList<out String?>> =
moshi.adapter<MutableList<out
String?>>(Types.newParameterizedType(MutableList::class.java,
Types.subtypeOf(String::class.java)), emptySet(), "nullableWildcardOut")
private val arrayOfStringAnyAdapter: JsonAdapter<Array<in String>> = moshi.adapter<Array<in
String>>(Types.arrayOf(Types.supertypeOf(String::class.java)), emptySet(), "wildcardIn")
private val listOfNullableAnyAdapter: JsonAdapter<List<*>> =
moshi.adapter<List<*>>(Types.newParameterizedType(List::class.java,
Types.subtypeOf(Any::class.java)), emptySet(), "any")
private val listOfAnyAdapter: JsonAdapter<List<Any>> =
moshi.adapter<List<Any>>(Types.newParameterizedType(List::class.java, Any::class.java),
emptySet(), "anyTwo")
private val mutableListOfAnyAdapter: JsonAdapter<MutableList<out Any>> =
moshi.adapter<MutableList<out Any>>(Types.newParameterizedType(MutableList::class.java,
Types.subtypeOf(Any::class.java)), emptySet(), "anyOut")
private val mutableListOfNullableAnyAdapter: JsonAdapter<MutableList<*>> =
moshi.adapter<MutableList<*>>(Types.newParameterizedType(MutableList::class.java,
Types.subtypeOf(Any::class.java)), emptySet(), "nullableAnyOut")
private val intArrayAdapter: JsonAdapter<IntArray> =
moshi.adapter<IntArray>(IntArray::class.java, emptySet(), "favoriteThreeNumbers")
private val arrayOfStringAdapter: JsonAdapter<Array<String>> =
moshi.adapter<Array<String>>(Types.arrayOf(String::class.java), emptySet(),
"favoriteArrayValues")
private val arrayOfNullableStringAdapter: JsonAdapter<Array<String?>> =
moshi.adapter<Array<String?>>(Types.arrayOf(String::class.java), emptySet(),
"favoriteNullableArrayValues")
private val nullableSetOfListOfMapOfStringArrayOfNullableIntArrayAdapter:
JsonAdapter<Set<List<Map<String, Array<IntArray?>>>>?> =
moshi.adapter<Set<List<Map<String,
Array<IntArray?>>>>?>(Types.newParameterizedType(Set::class.java,
Types.newParameterizedType(List::class.java, Types.newParameterizedType(Map::class.java,
String::class.java, Types.arrayOf(IntArray::class.java)))), emptySet(),
"nullableSetListMapArrayNullableIntWithDefault")
override fun toString(): String = "GeneratedJsonAdapter(SmokeTestType)"
override fun fromJson(reader: JsonReader): SmokeTestType {
var firstName: String? = null
var lastName: String? = null
var age: Int? = null
var nationalities: List<String>? = null
var nationalitiesSet: Boolean = false
var weight: Float? = null
var tattoos: Boolean? = false
var tattoosSet: Boolean = false
var race: String? = null
var hasChildren: Boolean? = false
var hasChildrenSet: Boolean = false
var favoriteFood: String? = null
var favoriteFoodSet: Boolean = false
var favoriteDrink: String? = null
var favoriteDrinkSet: Boolean = false
var wildcardOut: MutableList<out String>? = null
var wildcardOutSet: Boolean = false
var nullableWildcardOut: MutableList<out String?>? = null
var nullableWildcardOutSet: Boolean = false
var wildcardIn: Array<in String>? = null
var any: List<*>? = null
var anyTwo: List<Any>? = null
var anyOut: MutableList<out Any>? = null
var nullableAnyOut: MutableList<*>? = null
var favoriteThreeNumbers: IntArray? = null
var favoriteArrayValues: Array<String>? = null
var favoriteNullableArrayValues: Array<String?>? = null
var nullableSetListMapArrayNullableIntWithDefault: Set<List<Map<String, Array<IntArray?>>>>?
= null
var nullableSetListMapArrayNullableIntWithDefaultSet: Boolean = false
var aliasedName: String? = null
var aliasedNameSet: Boolean = false
var genericAlias: List<String>? = null
var genericAliasSet: Boolean = false
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> firstName = stringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("firstName").append("' was null at ").append(reader.path).toString())
1 -> lastName = stringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("lastName").append("' was null at ").append(reader.path).toString())
2 -> age = intAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("age").append("' was null at ").append(reader.path).toString())
3 -> {
nationalities = listOfStringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("nationalities").append("' was null at ").append(reader.path).toString())
nationalitiesSet = true
}
4 -> weight = floatAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("weight").append("' was null at ").append(reader.path).toString())
5 -> {
tattoos = booleanAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("tattoos").append("' was null at ").append(reader.path).toString())
tattoosSet = true
}
6 -> race = nullableStringAdapter.fromJson(reader)
7 -> {
hasChildren = booleanAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("hasChildren").append("' was null at ").append(reader.path).toString())
hasChildrenSet = true
}
8 -> {
favoriteFood = nullableStringAdapter.fromJson(reader)
favoriteFoodSet = true
}
9 -> {
favoriteDrink = nullableStringAdapter.fromJson(reader)
favoriteDrinkSet = true
}
10 -> {
wildcardOut = mutableListOfStringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("wildcardOut").append("' was null at ").append(reader.path).toString())
wildcardOutSet = true
}
11 -> {
nullableWildcardOut = mutableListOfNullableStringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("nullableWildcardOut").append("' was null at ").append(reader.path).toString())
nullableWildcardOutSet = true
}
12 -> wildcardIn = arrayOfStringAnyAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("wildcardIn").append("' was null at ").append(reader.path).toString())
13 -> any = listOfNullableAnyAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("any").append("' was null at ").append(reader.path).toString())
14 -> anyTwo = listOfAnyAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("anyTwo").append("' was null at ").append(reader.path).toString())
15 -> anyOut = mutableListOfAnyAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("anyOut").append("' was null at ").append(reader.path).toString())
16 -> nullableAnyOut = mutableListOfNullableAnyAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("nullableAnyOut").append("' was null at ").append(reader.path).toString())
17 -> favoriteThreeNumbers = intArrayAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("favoriteThreeNumbers").append("' was null at ").append(reader.path).toString())
18 -> favoriteArrayValues = arrayOfStringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("favoriteArrayValues").append("' was null at ").append(reader.path).toString())
19 -> favoriteNullableArrayValues = arrayOfNullableStringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("favoriteNullableArrayValues").append("' was null at ").append(reader.path).toString())
20 -> {
nullableSetListMapArrayNullableIntWithDefault =
nullableSetOfListOfMapOfStringArrayOfNullableIntArrayAdapter.fromJson(reader)
nullableSetListMapArrayNullableIntWithDefaultSet = true
}
21 -> {
aliasedName = stringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("aliasedName").append("' was null at ").append(reader.path).toString())
aliasedNameSet = true
}
22 -> {
genericAlias = listOfStringAdapter.fromJson(reader) ?:
throw JsonDataException(StringBuilder("Non-null value '").append("genericAlias").append("' was null at ").append(reader.path).toString())
genericAliasSet = true
}
-1 -> {
// Unknown name, skip it.
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
val localConstructor = this.constructorRef ?:
Util.lookupDefaultsConstructor(SmokeTestType::class.java).also {
this.constructorRef = it }
val mask = Util.createDefaultValuesParametersMask(true, true, true, nationalitiesSet, true,
tattoosSet, true, hasChildrenSet, favoriteFoodSet, favoriteDrinkSet, wildcardOutSet,
nullableWildcardOutSet, true, true, true, true, true, true, true, true,
nullableSetListMapArrayNullableIntWithDefaultSet, aliasedNameSet, genericAliasSet)
return Util.invokeDefaultConstructor(SmokeTestType::class.java, localConstructor, mask,
firstName ?:
throw JsonDataException(StringBuilder("Required property '").append("firstName").append("' missing at ").append(reader.path).toString()),
lastName ?:
throw JsonDataException(StringBuilder("Required property '").append("lastName").append("' missing at ").append(reader.path).toString()),
age ?:
throw JsonDataException(StringBuilder("Required property '").append("age").append("' missing at ").append(reader.path).toString()),
nationalities,
weight ?:
throw JsonDataException(StringBuilder("Required property '").append("weight").append("' missing at ").append(reader.path).toString()),
tattoos,
race,
hasChildren,
favoriteFood,
favoriteDrink,
wildcardOut,
nullableWildcardOut,
wildcardIn ?:
throw JsonDataException(StringBuilder("Required property '").append("wildcardIn").append("' missing at ").append(reader.path).toString()),
any ?:
throw JsonDataException(StringBuilder("Required property '").append("any").append("' missing at ").append(reader.path).toString()),
anyTwo ?:
throw JsonDataException(StringBuilder("Required property '").append("anyTwo").append("' missing at ").append(reader.path).toString()),
anyOut ?:
throw JsonDataException(StringBuilder("Required property '").append("anyOut").append("' missing at ").append(reader.path).toString()),
nullableAnyOut ?:
throw JsonDataException(StringBuilder("Required property '").append("nullableAnyOut").append("' missing at ").append(reader.path).toString()),
favoriteThreeNumbers ?:
throw JsonDataException(StringBuilder("Required property '").append("favoriteThreeNumbers").append("' missing at ").append(reader.path).toString()),
favoriteArrayValues ?:
throw JsonDataException(StringBuilder("Required property '").append("favoriteArrayValues").append("' missing at ").append(reader.path).toString()),
favoriteNullableArrayValues ?:
throw JsonDataException(StringBuilder("Required property '").append("favoriteNullableArrayValues").append("' missing at ").append(reader.path).toString()),
nullableSetListMapArrayNullableIntWithDefault,
aliasedName,
genericAlias
)
}
override fun toJson(writer: JsonWriter, value: SmokeTestType?) {
if (value == null) {
throw NullPointerException("value was null! Wrap in .nullSafe() to write nullable values.")
}
writer.beginObject()
writer.name("first_name")
stringAdapter.toJson(writer, value.firstName)
writer.name("last_name")
stringAdapter.toJson(writer, value.lastName)
writer.name("age")
intAdapter.toJson(writer, value.age)
writer.name("nationalities")
listOfStringAdapter.toJson(writer, value.nationalities)
writer.name("weight")
floatAdapter.toJson(writer, value.weight)
writer.name("tattoos")
booleanAdapter.toJson(writer, value.tattoos)
writer.name("race")
nullableStringAdapter.toJson(writer, value.race)
writer.name("hasChildren")
booleanAdapter.toJson(writer, value.hasChildren)
writer.name("favoriteFood")
nullableStringAdapter.toJson(writer, value.favoriteFood)
writer.name("favoriteDrink")
nullableStringAdapter.toJson(writer, value.favoriteDrink)
writer.name("wildcardOut")
mutableListOfStringAdapter.toJson(writer, value.wildcardOut)
writer.name("nullableWildcardOut")
mutableListOfNullableStringAdapter.toJson(writer, value.nullableWildcardOut)
writer.name("wildcardIn")
arrayOfStringAnyAdapter.toJson(writer, value.wildcardIn)
writer.name("any")
listOfNullableAnyAdapter.toJson(writer, value.any)
writer.name("anyTwo")
listOfAnyAdapter.toJson(writer, value.anyTwo)
writer.name("anyOut")
mutableListOfAnyAdapter.toJson(writer, value.anyOut)
writer.name("nullableAnyOut")
mutableListOfNullableAnyAdapter.toJson(writer, value.nullableAnyOut)
writer.name("favoriteThreeNumbers")
intArrayAdapter.toJson(writer, value.favoriteThreeNumbers)
writer.name("favoriteArrayValues")
arrayOfStringAdapter.toJson(writer, value.favoriteArrayValues)
writer.name("favoriteNullableArrayValues")
arrayOfNullableStringAdapter.toJson(writer, value.favoriteNullableArrayValues)
writer.name("nullableSetListMapArrayNullableIntWithDefault")
nullableSetOfListOfMapOfStringArrayOfNullableIntArrayAdapter.toJson(writer,
value.nullableSetListMapArrayNullableIntWithDefault)
writer.name("aliasedName")
stringAdapter.toJson(writer, value.aliasedName)
writer.name("genericAlias")
listOfStringAdapter.toJson(writer, value.genericAlias)
writer.endObject()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.