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

org.http4k.connect.amazon.model.KotshiSchemaConfigurationJsonAdapter.kt Maven / Gradle / Ivy

The newest version!
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.model

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import java.io.IOException
import java.lang.reflect.Constructor
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.setOf
import kotlin.jvm.Throws
import kotlin.jvm.Volatile
import kotlin.jvm.`internal`.DefaultConstructorMarker
import org.http4k.connect.amazon.core.model.ARN
import org.http4k.connect.amazon.core.model.Region
import se.ansman.kotshi.InternalKotshiApi
import se.ansman.kotshi.NamedJsonAdapter

@InternalKotshiApi
@Suppress(
  "DEPRECATION",
  "unused",
  "ClassName",
  "REDUNDANT_PROJECTION",
  "RedundantExplicitType",
  "LocalVariableName",
  "RedundantVisibilityModifier",
  "PLATFORM_CLASS_MAPPED_TO_KOTLIN",
  "IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION",
  "EXPERIMENTAL_API_USAGE",
  "OPT_IN_USAGE",
)
internal class KotshiSchemaConfigurationJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(SchemaConfiguration)") {
  private val regionAdapter: JsonAdapter = moshi.adapter(
      Region::class.javaObjectType,
      setOf(),
      "Region"
  )

  private val roleARNAdapter: JsonAdapter = moshi.adapter(
      ARN::class.javaObjectType,
      setOf(),
      "RoleARN"
  )

  private val options: JsonReader.Options = JsonReader.Options.of(
      "CatalogId",
      "DatabaseName",
      "Region",
      "RoleARN",
      "TableName",
      "VersionId"
  )

  @Volatile
  private var defaultConstructor: Constructor? = null

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: SchemaConfiguration?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("CatalogId").value(`value`.CatalogId)
      .name("DatabaseName").value(`value`.DatabaseName)
      .name("Region").apply {
        regionAdapter.toJson(this, `value`.Region)
      }
      .name("RoleARN").apply {
        roleARNAdapter.toJson(this, `value`.RoleARN)
      }
      .name("TableName").value(`value`.TableName)
      .name("VersionId").value(`value`.VersionId)
      .endObject()
  }

  @Throws(IOException::class)
  override fun fromJson(reader: JsonReader): SchemaConfiguration? {
    if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()

    var mask = -1
    var catalogId: String? = null
    var databaseName: String? = null
    var region: Region? = null
    var roleARN: ARN? = null
    var tableName: String? = null
    var versionId: String? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            catalogId = reader.nextString()
          }
          // $mask = $mask and (1 shl 0).inv()
          mask = mask and 0xfffffffe.toInt()
        }
        1 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            databaseName = reader.nextString()
          }
          // $mask = $mask and (1 shl 1).inv()
          mask = mask and 0xfffffffd.toInt()
        }
        2 -> {
          region = regionAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 2).inv()
          mask = mask and 0xfffffffb.toInt()
        }
        3 -> {
          roleARN = roleARNAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 3).inv()
          mask = mask and 0xfffffff7.toInt()
        }
        4 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            tableName = reader.nextString()
          }
          // $mask = $mask and (1 shl 4).inv()
          mask = mask and 0xffffffef.toInt()
        }
        5 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            versionId = reader.nextString()
          }
          // $mask = $mask and (1 shl 5).inv()
          mask = mask and 0xffffffdf.toInt()
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    return if (mask == 0xffffffc0.toInt()) {
      SchemaConfiguration(
          CatalogId = catalogId,
          DatabaseName = databaseName,
          Region = region,
          RoleARN = roleARN,
          TableName = tableName,
          VersionId = versionId
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor =
          this.defaultConstructor ?: SchemaConfiguration::class.java.getDeclaredConstructor(
            String::class.java,
            String::class.java,
            Region::class.java,
            ARN::class.java,
            String::class.java,
            String::class.java,
            Int::class.javaPrimitiveType,
            DefaultConstructorMarker::class.java
          ).also { this.defaultConstructor = it }
      localConstructor.newInstance(
          catalogId,
          databaseName,
          region,
          roleARN,
          tableName,
          versionId,
          mask,
          /* DefaultConstructorMarker */ null
      )
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy