All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sh.christian.ozone.api.lexicon.LexiconUnionReferenceJsonAdapter.kt Maven / Gradle / Ivy

The newest version!
// Code generated by moshi-kotlin-codegen. Do not edit.
@file:Suppress("DEPRECATION", "unused", "UNUSED_PARAMETER", "ClassName", "REDUNDANT_PROJECTION",
    "RedundantExplicitType", "LocalVariableName", "RedundantVisibilityModifier",
    "PLATFORM_CLASS_MAPPED_TO_KOTLIN", "IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION")

package sh.christian.ozone.api.lexicon

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 kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.emptySet
import kotlin.text.buildString

public class LexiconUnionReferenceJsonAdapter(
  moshi: Moshi,
) : JsonAdapter() {
  private val options: JsonReader.Options = JsonReader.Options.of("description", "refs", "closed")

  private val nullableStringAdapter: JsonAdapter = moshi.adapter(String::class.java,
      emptySet(), "description")

  private val listOfStringAdapter: JsonAdapter> =
      moshi.adapter(Types.newParameterizedType(List::class.java, String::class.java), emptySet(),
      "refs")

  private val nullableBooleanAdapter: JsonAdapter =
      moshi.adapter(Boolean::class.javaObjectType, emptySet(), "closed")

  public override fun toString(): String = buildString(43) {
      append("GeneratedJsonAdapter(").append("LexiconUnionReference").append(')') }

  public override fun fromJson(reader: JsonReader): LexiconUnionReference {
    var description: String? = null
    var refs: List? = null
    var closed: Boolean? = null
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> description = nullableStringAdapter.fromJson(reader)
        1 -> refs = listOfStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("refs",
            "refs", reader)
        2 -> closed = nullableBooleanAdapter.fromJson(reader)
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    return LexiconUnionReference(
        description = description,
        refs = refs ?: throw Util.missingProperty("refs", "refs", reader),
        closed = closed
    )
  }

  public override fun toJson(writer: JsonWriter, value_: LexiconUnionReference?): Unit {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("description")
    nullableStringAdapter.toJson(writer, value_.description)
    writer.name("refs")
    listOfStringAdapter.toJson(writer, value_.refs)
    writer.name("closed")
    nullableBooleanAdapter.toJson(writer, value_.closed)
    writer.endObject()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy