// 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
import kotlinx.parcelize.RawValue

public class SearchFiltersJsonAdapter(
  moshi: Moshi,
) : JsonAdapter<SearchFilters>() {
  private val options: JsonReader.Options = JsonReader.Options.of("id", "dateFrom", "dateTo",
      "feedIds", "authors", "contentType", "sortOption")

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

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

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

  private val nullableContentTypeAdapter: JsonAdapter<@RawValue ContentType?> =
      moshi.adapter(ContentType::class.java, emptySet(), "contentType")

  private val searchSortOptionAdapter: JsonAdapter<@RawValue SearchSortOption> =
      moshi.adapter(SearchSortOption::class.java, emptySet(), "sortOption")

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

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

  override fun fromJson(reader: JsonReader): SearchFilters {
    var id: String? = null
    var dateFrom: Date? = null
    var dateTo: Date? = null
    var feedIds: List<String>? = null
    var authors: List<String>? = null
    var contentType: @RawValue ContentType? = null
    var sortOption: @RawValue SearchSortOption? = null
    var mask0 = -1
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          id = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("id", "id", reader)
          // $mask = $mask and (1 shl 0).inv()
          mask0 = mask0 and 0xfffffffe.toInt()
        }
        1 -> {
          dateFrom = nullableDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 1).inv()
          mask0 = mask0 and 0xfffffffd.toInt()
        }
        2 -> {
          dateTo = nullableDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 2).inv()
          mask0 = mask0 and 0xfffffffb.toInt()
        }
        3 -> {
          feedIds = nullableListOfStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 3).inv()
          mask0 = mask0 and 0xfffffff7.toInt()
        }
        4 -> {
          authors = nullableListOfStringAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 4).inv()
          mask0 = mask0 and 0xffffffef.toInt()
        }
        5 -> {
          contentType = nullableContentTypeAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 5).inv()
          mask0 = mask0 and 0xffffffdf.toInt()
        }
        6 -> {
          sortOption = searchSortOptionAdapter.fromJson(reader) ?:
              throw Util.unexpectedNull("sortOption", "sortOption", reader)
          // $mask = $mask and (1 shl 6).inv()
          mask0 = mask0 and 0xffffffbf.toInt()
        }
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    if (mask0 == 0xffffff80.toInt()) {
      // All parameters with defaults are set, invoke the constructor directly
      return  SearchFilters(
          id = id as String,
          dateFrom = dateFrom,
          dateTo = dateTo,
          feedIds = feedIds,
          authors = authors,
          contentType = contentType,
          sortOption = sortOption as @RawValue SearchSortOption
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor<SearchFilters> = this.constructorRef ?:
          SearchFilters::class.java.getDeclaredConstructor(String::class.java, Date::class.java,
          Date::class.java, List::class.java, List::class.java, ContentType::class.java,
          SearchSortOption::class.java, Int::class.javaPrimitiveType,
          Util.DEFAULT_CONSTRUCTOR_MARKER).also { this.constructorRef = it }
      return localConstructor.newInstance(
          id,
          dateFrom,
          dateTo,
          feedIds,
          authors,
          contentType,
          sortOption,
          mask0,
          /* DefaultConstructorMarker */ null
      )
    }
  }

  override fun toJson(writer: JsonWriter, value_: SearchFilters?) {
    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("dateFrom")
    nullableDateAdapter.toJson(writer, value_.dateFrom)
    writer.name("dateTo")
    nullableDateAdapter.toJson(writer, value_.dateTo)
    writer.name("feedIds")
    nullableListOfStringAdapter.toJson(writer, value_.feedIds)
    writer.name("authors")
    nullableListOfStringAdapter.toJson(writer, value_.authors)
    writer.name("contentType")
    nullableContentTypeAdapter.toJson(writer, value_.contentType)
    writer.name("sortOption")
    searchSortOptionAdapter.toJson(writer, value_.sortOption)
    writer.endObject()
  }
}
