// 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.Types
import com.squareup.moshi.`internal`.Util
import java.lang.NullPointerException
import java.lang.reflect.Constructor
import java.util.Date
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.emptySet
import kotlin.jvm.Volatile
import kotlin.text.buildString

public class FeedJsonAdapter(
  moshi: Moshi,
) : JsonAdapter<Feed>() {
  private val options: JsonReader.Options = JsonReader.Options.of("id", "title", "link",
      "description", "subtitle", "language", "lastBuildDate", "updated", "generator", "ttl",
      "items", "rawUrl", "lastFetchedAt", "nextFetchAt")

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

  private val nullableStringAdapter: JsonAdapter<String?> = moshi.adapter(String::class.java,
      emptySet(), "link")

  private val nullableDateAdapter: JsonAdapter<Date?> = moshi.adapter(Date::class.java, emptySet(),
      "lastBuildDate")

  private val nullableIntAdapter: JsonAdapter<Int?> = moshi.adapter(Int::class.javaObjectType,
      emptySet(), "ttl")

  private val listOfFeedItemAdapter: JsonAdapter<List<FeedItem>> =
      moshi.adapter(Types.newParameterizedType(List::class.java, FeedItem::class.java), emptySet(),
      "items")

  @Volatile
  private var constructorRef: Constructor<Feed>? = null

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

  override fun fromJson(reader: JsonReader): Feed {
    var id: String? = null
    var title: String? = null
    var link: String? = null
    var description: String? = null
    var subtitle: String? = null
    var language: String? = null
    var lastBuildDate: Date? = null
    var updated: Date? = null
    var generator: String? = null
    var ttl: Int? = null
    var items: List<FeedItem>? = null
    var rawUrl: String? = null
    var lastFetchedAt: Date? = null
    var nextFetchAt: Date? = null
    var mask0 = -1
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> id = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("id", "id", reader)
        1 -> title = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("title", "title",
            reader)
        2 -> {
          link = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 2).inv()
          mask0 = mask0 and 0xfffffffb.toInt()
        }
        3 -> {
          description = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 3).inv()
          mask0 = mask0 and 0xfffffff7.toInt()
        }
        4 -> {
          subtitle = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 4).inv()
          mask0 = mask0 and 0xffffffef.toInt()
        }
        5 -> {
          language = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 5).inv()
          mask0 = mask0 and 0xffffffdf.toInt()
        }
        6 -> {
          lastBuildDate = nullableDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 6).inv()
          mask0 = mask0 and 0xffffffbf.toInt()
        }
        7 -> {
          updated = nullableDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 7).inv()
          mask0 = mask0 and 0xffffff7f.toInt()
        }
        8 -> {
          generator = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 8).inv()
          mask0 = mask0 and 0xfffffeff.toInt()
        }
        9 -> {
          ttl = nullableIntAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 9).inv()
          mask0 = mask0 and 0xfffffdff.toInt()
        }
        10 -> {
          items = listOfFeedItemAdapter.fromJson(reader) ?: throw Util.unexpectedNull("items",
              "items", reader)
          // $mask = $mask and (1 shl 10).inv()
          mask0 = mask0 and 0xfffffbff.toInt()
        }
        11 -> rawUrl = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("rawUrl",
            "rawUrl", reader)
        12 -> {
          lastFetchedAt = nullableDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 12).inv()
          mask0 = mask0 and 0xffffefff.toInt()
        }
        13 -> {
          nextFetchAt = nullableDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 13).inv()
          mask0 = mask0 and 0xffffdfff.toInt()
        }
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    if (mask0 == 0xffffc803.toInt()) {
      // All parameters with defaults are set, invoke the constructor directly
      return  Feed(
          id = id ?: throw Util.missingProperty("id", "id", reader),
          title = title ?: throw Util.missingProperty("title", "title", reader),
          link = link,
          description = description,
          subtitle = subtitle,
          language = language,
          lastBuildDate = lastBuildDate,
          updated = updated,
          generator = generator,
          ttl = ttl,
          items = items as List<FeedItem>,
          rawUrl = rawUrl ?: throw Util.missingProperty("rawUrl", "rawUrl", reader),
          lastFetchedAt = lastFetchedAt,
          nextFetchAt = nextFetchAt
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor<Feed> = this.constructorRef ?:
          Feed::class.java.getDeclaredConstructor(String::class.java, String::class.java,
          String::class.java, String::class.java, String::class.java, String::class.java,
          Date::class.java, Date::class.java, String::class.java, Int::class.javaObjectType,
          List::class.java, String::class.java, Date::class.java, Date::class.java,
          Int::class.javaPrimitiveType, Util.DEFAULT_CONSTRUCTOR_MARKER).also {
          this.constructorRef = it }
      return localConstructor.newInstance(
          id ?: throw Util.missingProperty("id", "id", reader),
          title ?: throw Util.missingProperty("title", "title", reader),
          link,
          description,
          subtitle,
          language,
          lastBuildDate,
          updated,
          generator,
          ttl,
          items,
          rawUrl ?: throw Util.missingProperty("rawUrl", "rawUrl", reader),
          lastFetchedAt,
          nextFetchAt,
          mask0,
          /* DefaultConstructorMarker */ null
      )
    }
  }

  override fun toJson(writer: JsonWriter, value_: Feed?) {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("id")
    stringAdapter.toJson(writer, value_.id)
    writer.name("title")
    stringAdapter.toJson(writer, value_.title)
    writer.name("link")
    nullableStringAdapter.toJson(writer, value_.link)
    writer.name("description")
    nullableStringAdapter.toJson(writer, value_.description)
    writer.name("subtitle")
    nullableStringAdapter.toJson(writer, value_.subtitle)
    writer.name("language")
    nullableStringAdapter.toJson(writer, value_.language)
    writer.name("lastBuildDate")
    nullableDateAdapter.toJson(writer, value_.lastBuildDate)
    writer.name("updated")
    nullableDateAdapter.toJson(writer, value_.updated)
    writer.name("generator")
    nullableStringAdapter.toJson(writer, value_.generator)
    writer.name("ttl")
    nullableIntAdapter.toJson(writer, value_.ttl)
    writer.name("items")
    listOfFeedItemAdapter.toJson(writer, value_.items)
    writer.name("rawUrl")
    stringAdapter.toJson(writer, value_.rawUrl)
    writer.name("lastFetchedAt")
    nullableDateAdapter.toJson(writer, value_.lastFetchedAt)
    writer.name("nextFetchAt")
    nullableDateAdapter.toJson(writer, value_.nextFetchAt)
    writer.endObject()
  }
}
