// 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 java.lang.reflect.Constructor
import java.util.Date
import kotlin.Boolean
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.collections.emptySet
import kotlin.jvm.Volatile
import kotlin.text.buildString

public class FeedSubscriptionJsonAdapter(
  moshi: Moshi,
) : JsonAdapter<FeedSubscription>() {
  private val options: JsonReader.Options = JsonReader.Options.of("id", "url", "title", "category",
      "enabled", "fetchInterval", "createdAt", "updatedAt", "lastFetchedAt", "nextFetchAt", "error",
      "httpAuth")

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

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

  private val booleanAdapter: JsonAdapter<Boolean> = moshi.adapter(Boolean::class.java, emptySet(),
      "enabled")

  private val longAdapter: JsonAdapter<Long> = moshi.adapter(Long::class.java, emptySet(),
      "fetchInterval")

  private val dateAdapter: JsonAdapter<Date> = moshi.adapter(Date::class.java, emptySet(),
      "createdAt")

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

  private val nullableHttpAuthAdapter: JsonAdapter<HttpAuth?> = moshi.adapter(HttpAuth::class.java,
      emptySet(), "httpAuth")

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

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

  override fun fromJson(reader: JsonReader): FeedSubscription {
    var id: String? = null
    var url: String? = null
    var title: String? = null
    var category: String? = null
    var enabled: Boolean? = false
    var fetchInterval: Long? = null
    var createdAt: Date? = null
    var updatedAt: Date? = null
    var lastFetchedAt: Date? = null
    var nextFetchAt: Date? = null
    var error: String? = null
    var httpAuth: HttpAuth? = 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 -> url = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("url", "url", reader)
        2 -> title = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("title", "title",
            reader)
        3 -> {
          category = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 3).inv()
          mask0 = mask0 and 0xfffffff7.toInt()
        }
        4 -> {
          enabled = booleanAdapter.fromJson(reader) ?: throw Util.unexpectedNull("enabled",
              "enabled", reader)
          // $mask = $mask and (1 shl 4).inv()
          mask0 = mask0 and 0xffffffef.toInt()
        }
        5 -> fetchInterval = longAdapter.fromJson(reader) ?:
            throw Util.unexpectedNull("fetchInterval", "fetchInterval", reader)
        6 -> createdAt = dateAdapter.fromJson(reader) ?: throw Util.unexpectedNull("createdAt",
            "createdAt", reader)
        7 -> updatedAt = dateAdapter.fromJson(reader) ?: throw Util.unexpectedNull("updatedAt",
            "updatedAt", reader)
        8 -> {
          lastFetchedAt = nullableDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 8).inv()
          mask0 = mask0 and 0xfffffeff.toInt()
        }
        9 -> {
          nextFetchAt = nullableDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 9).inv()
          mask0 = mask0 and 0xfffffdff.toInt()
        }
        10 -> {
          error = nullableStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 10).inv()
          mask0 = mask0 and 0xfffffbff.toInt()
        }
        11 -> {
          httpAuth = nullableHttpAuthAdapter.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 == 0xfffff0e7.toInt()) {
      // All parameters with defaults are set, invoke the constructor directly
      return  FeedSubscription(
          id = id ?: throw Util.missingProperty("id", "id", reader),
          url = url ?: throw Util.missingProperty("url", "url", reader),
          title = title ?: throw Util.missingProperty("title", "title", reader),
          category = category,
          enabled = enabled as Boolean,
          fetchInterval = fetchInterval ?: throw Util.missingProperty("fetchInterval",
              "fetchInterval", reader),
          createdAt = createdAt ?: throw Util.missingProperty("createdAt", "createdAt", reader),
          updatedAt = updatedAt ?: throw Util.missingProperty("updatedAt", "updatedAt", reader),
          lastFetchedAt = lastFetchedAt,
          nextFetchAt = nextFetchAt,
          error = error,
          httpAuth = httpAuth
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor<FeedSubscription> = this.constructorRef ?:
          FeedSubscription::class.java.getDeclaredConstructor(String::class.java,
          String::class.java, String::class.java, String::class.java,
          Boolean::class.javaPrimitiveType, Long::class.javaPrimitiveType, Date::class.java,
          Date::class.java, Date::class.java, Date::class.java, String::class.java,
          HttpAuth::class.java, Int::class.javaPrimitiveType,
          Util.DEFAULT_CONSTRUCTOR_MARKER).also { this.constructorRef = it }
      return localConstructor.newInstance(
          id ?: throw Util.missingProperty("id", "id", reader),
          url ?: throw Util.missingProperty("url", "url", reader),
          title ?: throw Util.missingProperty("title", "title", reader),
          category,
          enabled,
          fetchInterval ?: throw Util.missingProperty("fetchInterval", "fetchInterval", reader),
          createdAt ?: throw Util.missingProperty("createdAt", "createdAt", reader),
          updatedAt ?: throw Util.missingProperty("updatedAt", "updatedAt", reader),
          lastFetchedAt,
          nextFetchAt,
          error,
          httpAuth,
          mask0,
          /* DefaultConstructorMarker */ null
      )
    }
  }

  override fun toJson(writer: JsonWriter, value_: FeedSubscription?) {
    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("url")
    stringAdapter.toJson(writer, value_.url)
    writer.name("title")
    stringAdapter.toJson(writer, value_.title)
    writer.name("category")
    nullableStringAdapter.toJson(writer, value_.category)
    writer.name("enabled")
    booleanAdapter.toJson(writer, value_.enabled)
    writer.name("fetchInterval")
    longAdapter.toJson(writer, value_.fetchInterval)
    writer.name("createdAt")
    dateAdapter.toJson(writer, value_.createdAt)
    writer.name("updatedAt")
    dateAdapter.toJson(writer, value_.updatedAt)
    writer.name("lastFetchedAt")
    nullableDateAdapter.toJson(writer, value_.lastFetchedAt)
    writer.name("nextFetchAt")
    nullableDateAdapter.toJson(writer, value_.nextFetchAt)
    writer.name("error")
    nullableStringAdapter.toJson(writer, value_.error)
    writer.name("httpAuth")
    nullableHttpAuthAdapter.toJson(writer, value_.httpAuth)
    writer.endObject()
  }
}
