Created
September 11, 2019 07:50
-
-
Save ZacSweers/04d92c637e0b4d5ad5ac2aa991969698 to your computer and use it in GitHub Desktop.
Revisions
-
ZacSweers created this gist
Sep 11, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,302 @@ // Code generated by moshi-kotlin-codegen. Do not edit. package com.squareup.moshi.kotlin.codgen import com.squareup.moshi.JsonAdapter 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.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 weight: Float? = null var tattoos: Boolean? = false var race: String? = null var hasChildren: Boolean? = false var favoriteFood: String? = null var favoriteDrink: String? = null var wildcardOut: MutableList<out String>? = null var nullableWildcardOut: MutableList<out String?>? = null 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 aliasedName: String? = null var genericAlias: List<String>? = null var mask = 0.inv() reader.beginObject() while (reader.hasNext()) { when (reader.selectName(options)) { 0 -> firstName = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("firstName", reader) 1 -> lastName = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("lastName", reader) 2 -> age = intAdapter.fromJson(reader) ?: throw Util.unexpectedNull("age", reader) 3 -> { nationalities = listOfStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("nationalities", reader) mask = mask and (1 shl 3).inv() } 4 -> weight = floatAdapter.fromJson(reader) ?: throw Util.unexpectedNull("weight", reader) 5 -> { tattoos = booleanAdapter.fromJson(reader) ?: throw Util.unexpectedNull("tattoos", reader) mask = mask and (1 shl 5).inv() } 6 -> race = nullableStringAdapter.fromJson(reader) 7 -> { hasChildren = booleanAdapter.fromJson(reader) ?: throw Util.unexpectedNull("hasChildren", reader) mask = mask and (1 shl 7).inv() } 8 -> { favoriteFood = nullableStringAdapter.fromJson(reader) mask = mask and (1 shl 8).inv() } 9 -> { favoriteDrink = nullableStringAdapter.fromJson(reader) mask = mask and (1 shl 9).inv() } 10 -> { wildcardOut = mutableListOfStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("wildcardOut", reader) mask = mask and (1 shl 10).inv() } 11 -> { nullableWildcardOut = mutableListOfNullableStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("nullableWildcardOut", reader) mask = mask and (1 shl 11).inv() } 12 -> wildcardIn = arrayOfStringAnyAdapter.fromJson(reader) ?: throw Util.unexpectedNull("wildcardIn", reader) 13 -> any = listOfNullableAnyAdapter.fromJson(reader) ?: throw Util.unexpectedNull("any", reader) 14 -> anyTwo = listOfAnyAdapter.fromJson(reader) ?: throw Util.unexpectedNull("anyTwo", reader) 15 -> anyOut = mutableListOfAnyAdapter.fromJson(reader) ?: throw Util.unexpectedNull("anyOut", reader) 16 -> nullableAnyOut = mutableListOfNullableAnyAdapter.fromJson(reader) ?: throw Util.unexpectedNull("nullableAnyOut", reader) 17 -> favoriteThreeNumbers = intArrayAdapter.fromJson(reader) ?: throw Util.unexpectedNull("favoriteThreeNumbers", reader) 18 -> favoriteArrayValues = arrayOfStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("favoriteArrayValues", reader) 19 -> favoriteNullableArrayValues = arrayOfNullableStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("favoriteNullableArrayValues", reader) 20 -> { nullableSetListMapArrayNullableIntWithDefault = nullableSetOfListOfMapOfStringArrayOfNullableIntArrayAdapter.fromJson(reader) mask = mask and (1 shl 20).inv() } 21 -> { aliasedName = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("aliasedName", reader) mask = mask and (1 shl 21).inv() } 22 -> { genericAlias = listOfStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("genericAlias", reader) mask = mask and (1 shl 22).inv() } -1 -> { // Unknown name, skip it. reader.skipName() reader.skipValue() } } } reader.endObject() val localConstructor = this.constructorRef ?: Util.lookupDefaultsConstructor(SmokeTestType::class.java).also { this.constructorRef = it } return localConstructor.newInstance( firstName ?: throw Util.missingProperty("firstName", reader), lastName ?: throw Util.missingProperty("lastName", reader), age ?: throw Util.missingProperty("age", reader), nationalities, weight ?: throw Util.missingProperty("weight", reader), tattoos, race, hasChildren, favoriteFood, favoriteDrink, wildcardOut, nullableWildcardOut, wildcardIn ?: throw Util.missingProperty("wildcardIn", reader), any ?: throw Util.missingProperty("any", reader), anyTwo ?: throw Util.missingProperty("anyTwo", reader), anyOut ?: throw Util.missingProperty("anyOut", reader), nullableAnyOut ?: throw Util.missingProperty("nullableAnyOut", reader), favoriteThreeNumbers ?: throw Util.missingProperty("favoriteThreeNumbers", reader), favoriteArrayValues ?: throw Util.missingProperty("favoriteArrayValues", reader), favoriteNullableArrayValues ?: throw Util.missingProperty("favoriteNullableArrayValues", reader), nullableSetListMapArrayNullableIntWithDefault, aliasedName, genericAlias, mask, null ) } 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() } }