All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sh.christian.ozone.api.lexicon.LexiconStringJsonAdapter.kt Maven / Gradle / Ivy

The newest version!
// 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 sh.christian.ozone.api.lexicon

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 kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.emptySet
import kotlin.jvm.Volatile
import kotlin.text.buildString

public class LexiconStringJsonAdapter(
  moshi: Moshi,
) : JsonAdapter() {
  private val options: JsonReader.Options = JsonReader.Options.of("format", "description",
      "default", "minLength", "maxLength", "minGraphemes", "maxGraphemes", "enum", "const",
      "knownValues")

  private val nullableLexiconStringFormatAdapter: JsonAdapter =
      moshi.adapter(LexiconStringFormat::class.java, emptySet(), "format")

  private val nullableStringAdapter: JsonAdapter = moshi.adapter(String::class.java,
      emptySet(), "description")

  private val nullableLongAdapter: JsonAdapter = moshi.adapter(Long::class.javaObjectType,
      emptySet(), "minLength")

  private val listOfStringAdapter: JsonAdapter> =
      moshi.adapter(Types.newParameterizedType(List::class.java, String::class.java), emptySet(),
      "enum")

  @Volatile
  private var constructorRef: Constructor? = null

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

  public override fun fromJson(reader: JsonReader): LexiconString {
    var format: LexiconStringFormat? = null
    var description: String? = null
    var default: String? = null
    var minLength: Long? = null
    var maxLength: Long? = null
    var minGraphemes: Long? = null
    var maxGraphemes: Long? = null
    var enum_: List? = null
    var const_: String? = null
    var knownValues: List? = null
    var mask0 = -1
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> format = nullableLexiconStringFormatAdapter.fromJson(reader)
        1 -> description = nullableStringAdapter.fromJson(reader)
        2 -> default = nullableStringAdapter.fromJson(reader)
        3 -> minLength = nullableLongAdapter.fromJson(reader)
        4 -> maxLength = nullableLongAdapter.fromJson(reader)
        5 -> minGraphemes = nullableLongAdapter.fromJson(reader)
        6 -> maxGraphemes = nullableLongAdapter.fromJson(reader)
        7 -> {
          enum_ = listOfStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("enum_", "enum",
              reader)
          // $mask = $mask and (1 shl 7).inv()
          mask0 = mask0 and 0xffffff7f.toInt()
        }
        8 -> const_ = nullableStringAdapter.fromJson(reader)
        9 -> {
          knownValues = listOfStringAdapter.fromJson(reader) ?:
              throw Util.unexpectedNull("knownValues", "knownValues", reader)
          // $mask = $mask and (1 shl 9).inv()
          mask0 = mask0 and 0xfffffdff.toInt()
        }
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    if (mask0 == 0xfffffd7f.toInt()) {
      // All parameters with defaults are set, invoke the constructor directly
      return  LexiconString(
          format = format,
          description = description,
          default = default,
          minLength = minLength,
          maxLength = maxLength,
          minGraphemes = minGraphemes,
          maxGraphemes = maxGraphemes,
          `enum` = enum_ as List,
          `const` = const_,
          knownValues = knownValues as List
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor = this.constructorRef ?:
          LexiconString::class.java.getDeclaredConstructor(LexiconStringFormat::class.java,
          String::class.java, String::class.java, Long::class.javaObjectType,
          Long::class.javaObjectType, Long::class.javaObjectType, Long::class.javaObjectType,
          List::class.java, String::class.java, List::class.java, Int::class.javaPrimitiveType,
          Util.DEFAULT_CONSTRUCTOR_MARKER).also { this.constructorRef = it }
      return localConstructor.newInstance(
          format,
          description,
          default,
          minLength,
          maxLength,
          minGraphemes,
          maxGraphemes,
          enum_,
          const_,
          knownValues,
          mask0,
          /* DefaultConstructorMarker */ null
      )
    }
  }

  public override fun toJson(writer: JsonWriter, value_: LexiconString?): Unit {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("format")
    nullableLexiconStringFormatAdapter.toJson(writer, value_.format)
    writer.name("description")
    nullableStringAdapter.toJson(writer, value_.description)
    writer.name("default")
    nullableStringAdapter.toJson(writer, value_.default)
    writer.name("minLength")
    nullableLongAdapter.toJson(writer, value_.minLength)
    writer.name("maxLength")
    nullableLongAdapter.toJson(writer, value_.maxLength)
    writer.name("minGraphemes")
    nullableLongAdapter.toJson(writer, value_.minGraphemes)
    writer.name("maxGraphemes")
    nullableLongAdapter.toJson(writer, value_.maxGraphemes)
    writer.name("enum")
    listOfStringAdapter.toJson(writer, value_.`enum`)
    writer.name("const")
    nullableStringAdapter.toJson(writer, value_.`const`)
    writer.name("knownValues")
    listOfStringAdapter.toJson(writer, value_.knownValues)
    writer.endObject()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy