// 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 kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.collections.emptySet
import kotlin.jvm.Volatile
import kotlin.text.buildString
import kotlinx.parcelize.RawValue

public class ReadingPreferencesJsonAdapter(
  moshi: Moshi,
) : JsonAdapter<ReadingPreferences>() {
  private val options: JsonReader.Options = JsonReader.Options.of("id", "fontSize", "lineHeight",
      "showTableOfContents", "showReadingTime", "showAuthor", "showDate")

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

  private val fontSizeAdapter: JsonAdapter<@RawValue FontSize> = moshi.adapter(FontSize::class.java,
      emptySet(), "fontSize")

  private val lineHeightAdapter: JsonAdapter<@RawValue LineHeight> =
      moshi.adapter(LineHeight::class.java, emptySet(), "lineHeight")

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

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

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

  override fun fromJson(reader: JsonReader): ReadingPreferences {
    var id: String? = null
    var fontSize: @RawValue FontSize? = null
    var lineHeight: @RawValue LineHeight? = null
    var showTableOfContents: Boolean? = false
    var showReadingTime: Boolean? = false
    var showAuthor: Boolean? = false
    var showDate: Boolean? = false
    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 -> {
          fontSize = fontSizeAdapter.fromJson(reader) ?: throw Util.unexpectedNull("fontSize",
              "fontSize", reader)
          // $mask = $mask and (1 shl 1).inv()
          mask0 = mask0 and 0xfffffffd.toInt()
        }
        2 -> {
          lineHeight = lineHeightAdapter.fromJson(reader) ?: throw Util.unexpectedNull("lineHeight",
              "lineHeight", reader)
          // $mask = $mask and (1 shl 2).inv()
          mask0 = mask0 and 0xfffffffb.toInt()
        }
        3 -> {
          showTableOfContents = booleanAdapter.fromJson(reader) ?:
              throw Util.unexpectedNull("showTableOfContents", "showTableOfContents", reader)
          // $mask = $mask and (1 shl 3).inv()
          mask0 = mask0 and 0xfffffff7.toInt()
        }
        4 -> {
          showReadingTime = booleanAdapter.fromJson(reader) ?:
              throw Util.unexpectedNull("showReadingTime", "showReadingTime", reader)
          // $mask = $mask and (1 shl 4).inv()
          mask0 = mask0 and 0xffffffef.toInt()
        }
        5 -> {
          showAuthor = booleanAdapter.fromJson(reader) ?: throw Util.unexpectedNull("showAuthor",
              "showAuthor", reader)
          // $mask = $mask and (1 shl 5).inv()
          mask0 = mask0 and 0xffffffdf.toInt()
        }
        6 -> {
          showDate = booleanAdapter.fromJson(reader) ?: throw Util.unexpectedNull("showDate",
              "showDate", 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  ReadingPreferences(
          id = id as String,
          fontSize = fontSize as @RawValue FontSize,
          lineHeight = lineHeight as @RawValue LineHeight,
          showTableOfContents = showTableOfContents as Boolean,
          showReadingTime = showReadingTime as Boolean,
          showAuthor = showAuthor as Boolean,
          showDate = showDate as Boolean
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor<ReadingPreferences> = this.constructorRef ?:
          ReadingPreferences::class.java.getDeclaredConstructor(String::class.java,
          FontSize::class.java, LineHeight::class.java, Boolean::class.javaPrimitiveType,
          Boolean::class.javaPrimitiveType, Boolean::class.javaPrimitiveType,
          Boolean::class.javaPrimitiveType, Int::class.javaPrimitiveType,
          Util.DEFAULT_CONSTRUCTOR_MARKER).also { this.constructorRef = it }
      return localConstructor.newInstance(
          id,
          fontSize,
          lineHeight,
          showTableOfContents,
          showReadingTime,
          showAuthor,
          showDate,
          mask0,
          /* DefaultConstructorMarker */ null
      )
    }
  }

  override fun toJson(writer: JsonWriter, value_: ReadingPreferences?) {
    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("fontSize")
    fontSizeAdapter.toJson(writer, value_.fontSize)
    writer.name("lineHeight")
    lineHeightAdapter.toJson(writer, value_.lineHeight)
    writer.name("showTableOfContents")
    booleanAdapter.toJson(writer, value_.showTableOfContents)
    writer.name("showReadingTime")
    booleanAdapter.toJson(writer, value_.showReadingTime)
    writer.name("showAuthor")
    booleanAdapter.toJson(writer, value_.showAuthor)
    writer.name("showDate")
    booleanAdapter.toJson(writer, value_.showDate)
    writer.endObject()
  }
}
