// 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.rssuper.models

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.`internal`.Util
import java.lang.NullPointerException
import kotlin.String
import kotlin.Suppress
import kotlin.collections.emptySet
import kotlin.text.buildString

public class HttpAuthJsonAdapter(
  moshi: Moshi,
) : JsonAdapter<HttpAuth>() {
  private val options: JsonReader.Options = JsonReader.Options.of("username", "password")

  private val stringAdapter: JsonAdapter<String> = moshi.adapter(String::class.java, emptySet(),
      "username")

  override fun toString(): String = buildString(30) {
      append("GeneratedJsonAdapter(").append("HttpAuth").append(')') }

  override fun fromJson(reader: JsonReader): HttpAuth {
    var username: String? = null
    var password: String? = null
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> username = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("username",
            "username", reader)
        1 -> password = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("password",
            "password", reader)
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    return HttpAuth(
        username = username ?: throw Util.missingProperty("username", "username", reader),
        password = password ?: throw Util.missingProperty("password", "password", reader)
    )
  }

  override fun toJson(writer: JsonWriter, value_: HttpAuth?) {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("username")
    stringAdapter.toJson(writer, value_.username)
    writer.name("password")
    stringAdapter.toJson(writer, value_.password)
    writer.endObject()
  }
}
