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

com.connectrpc.protocols.EndStreamResponseJSONJsonAdapter.kt Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show 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 com.connectrpc.protocols

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 java.lang.NullPointerException
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.collections.emptySet
import kotlin.text.buildString

internal class EndStreamResponseJSONJsonAdapter(
  moshi: Moshi,
) : JsonAdapter() {
  private val options: JsonReader.Options = JsonReader.Options.of("error", "metadata")

  private val nullableErrorPayloadJSONAdapter: JsonAdapter =
      moshi.adapter(ErrorPayloadJSON::class.java, emptySet(), "error")

  private val nullableMapOfStringListOfStringAdapter: JsonAdapter>?> =
      moshi.adapter(Types.newParameterizedType(Map::class.java, String::class.java,
      Types.newParameterizedType(List::class.java, String::class.java)), emptySet(), "metadata")

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

  public override fun fromJson(reader: JsonReader): EndStreamResponseJSON {
    var error: ErrorPayloadJSON? = null
    var metadata: Map>? = null
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> error = nullableErrorPayloadJSONAdapter.fromJson(reader)
        1 -> metadata = nullableMapOfStringListOfStringAdapter.fromJson(reader)
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    return EndStreamResponseJSON(
        error = error,
        metadata = metadata
    )
  }

  public override fun toJson(writer: JsonWriter, value_: EndStreamResponseJSON?): Unit {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("error")
    nullableErrorPayloadJSONAdapter.toJson(writer, value_.error)
    writer.name("metadata")
    nullableMapOfStringListOfStringAdapter.toJson(writer, value_.metadata)
    writer.endObject()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy