// 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 FeedItemJsonAdapter(
  moshi: Moshi,
) : JsonAdapter<FeedItem>() {
  private val options: JsonReader.Options = JsonReader.Options.of("id", "title", "link",
      "description", "content", "author", "published", "updated", "categories", "enclosure", "guid",
      "subscriptionTitle")

  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(),
      "published")

  private val nullableListOfStringAdapter: JsonAdapter<List<String>?> =
      moshi.adapter(Types.newParameterizedType(List::class.java, String::class.java), emptySet(),
      "categories")

  private val nullableEnclosureAdapter: JsonAdapter<Enclosure?> =
      moshi.adapter(Enclosure::class.java, emptySet(), "enclosure")

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

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

  override fun fromJson(reader: JsonReader): FeedItem {
    var id: String? = null
    var title: String? = null
    var link: String? = null
    var description: String? = null
    var content: String? = null
    var author: String? = null
    var published: Date? = null
    var updated: Date? = null
    var categories: List<String>? = null
    var enclosure: Enclosure? = null
    var guid: String? = null
    var subscriptionTitle: String? = 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 -> {
          content = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 4).inv()
          mask0 = mask0 and 0xffffffef.toInt()
        }
        5 -> {
          author = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 5).inv()
          mask0 = mask0 and 0xffffffdf.toInt()
        }
        6 -> {
          published = 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 -> {
          categories = nullableListOfStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 8).inv()
          mask0 = mask0 and 0xfffffeff.toInt()
        }
        9 -> {
          enclosure = nullableEnclosureAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 9).inv()
          mask0 = mask0 and 0xfffffdff.toInt()
        }
        10 -> {
          guid = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 10).inv()
          mask0 = mask0 and 0xfffffbff.toInt()
        }
        11 -> {
          subscriptionTitle = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 11).inv()
          mask0 = mask0 and 0xfffff7ff.toInt()
        }
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    if (mask0 == 0xfffff003.toInt()) {
      // All parameters with defaults are set, invoke the constructor directly
      return  FeedItem(
          id = id ?: throw Util.missingProperty("id", "id", reader),
          title = title ?: throw Util.missingProperty("title", "title", reader),
          link = link,
          description = description,
          content = content,
          author = author,
          published = published,
          updated = updated,
          categories = categories,
          enclosure = enclosure,
          guid = guid,
          subscriptionTitle = subscriptionTitle
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor<FeedItem> = this.constructorRef ?:
          FeedItem::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, List::class.java, Enclosure::class.java,
          String::class.java, String::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,
          content,
          author,
          published,
          updated,
          categories,
          enclosure,
          guid,
          subscriptionTitle,
          mask0,
          /* DefaultConstructorMarker */ null
      )
    }
  }

  override fun toJson(writer: JsonWriter, value_: FeedItem?) {
    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("content")
    nullableStringAdapter.toJson(writer, value_.content)
    writer.name("author")
    nullableStringAdapter.toJson(writer, value_.author)
    writer.name("published")
    nullableDateAdapter.toJson(writer, value_.published)
    writer.name("updated")
    nullableDateAdapter.toJson(writer, value_.updated)
    writer.name("categories")
    nullableListOfStringAdapter.toJson(writer, value_.categories)
    writer.name("enclosure")
    nullableEnclosureAdapter.toJson(writer, value_.enclosure)
    writer.name("guid")
    nullableStringAdapter.toJson(writer, value_.guid)
    writer.name("subscriptionTitle")
    nullableStringAdapter.toJson(writer, value_.subscriptionTitle)
    writer.endObject()
  }
}
