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

org.http4k.connect.amazon.model.KotshiSerializerJsonAdapter.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.Suppress
import kotlin.apply
import kotlin.collections.setOf
import kotlin.jvm.Throws
import kotlin.jvm.Volatile
import kotlin.jvm.`internal`.DefaultConstructorMarker
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 KotshiSerializerJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(Serializer)") {
  private val orcSerDeAdapter: JsonAdapter = moshi.adapter(
      OrcSerDe::class.javaObjectType,
      setOf(),
      "OrcSerDe"
  )

  private val parquetSerDeAdapter: JsonAdapter = moshi.adapter(
      ParquetSerDe::class.javaObjectType,
      setOf(),
      "ParquetSerDe"
  )

  private val options: JsonReader.Options = JsonReader.Options.of(
      "OrcSerDe",
      "ParquetSerDe"
  )

  @Volatile
  private var defaultConstructor: Constructor? = null

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: Serializer?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("OrcSerDe").apply {
        orcSerDeAdapter.toJson(this, `value`.OrcSerDe)
      }
      .name("ParquetSerDe").apply {
        parquetSerDeAdapter.toJson(this, `value`.ParquetSerDe)
      }
      .endObject()
  }

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

    var mask = -1
    var orcSerDe: OrcSerDe? = null
    var parquetSerDe: ParquetSerDe? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          orcSerDe = orcSerDeAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 0).inv()
          mask = mask and 0xfffffffe.toInt()
        }
        1 -> {
          parquetSerDe = parquetSerDeAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 1).inv()
          mask = mask and 0xfffffffd.toInt()
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    return if (mask == 0xfffffffc.toInt()) {
      Serializer(
          OrcSerDe = orcSerDe,
          ParquetSerDe = parquetSerDe
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor =
          this.defaultConstructor ?: Serializer::class.java.getDeclaredConstructor(
            OrcSerDe::class.java,
            ParquetSerDe::class.java,
            Int::class.javaPrimitiveType,
            DefaultConstructorMarker::class.java
          ).also { this.defaultConstructor = it }
      localConstructor.newInstance(
          orcSerDe,
          parquetSerDe,
          mask,
          /* DefaultConstructorMarker */ null
      )
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy