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

org.http4k.connect.amazon.sqs.action.KotshiQueueAttributesJsonAdapter.kt Maven / Gradle / Ivy

// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.sqs.action

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.newParameterizedType
import java.io.IOException
import java.lang.reflect.Constructor
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.Map
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 KotshiQueueAttributesJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(QueueAttributes)") {
  private val attributesAdapter: JsonAdapter> = moshi.adapter(
      newParameterizedType(Map::class.javaObjectType, String::class.javaObjectType, String::class.javaObjectType),
      setOf(),
      "attributes"
  )

  private val options: JsonReader.Options = JsonReader.Options.of("Attributes")

  @Volatile
  private var defaultConstructor: Constructor? = null

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: QueueAttributes?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("Attributes").apply {
        attributesAdapter.toJson(this, `value`.attributes)
      }
      .endObject()
  }

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

    var mask = -1
    var attributes: Map? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          attributes = attributesAdapter.fromJson(reader)
            ?.also {
              // $mask = $mask and (1 shl 0).inv()
              mask = mask and 0xfffffffe.toInt()
            }
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    return if (mask == 0xfffffffe.toInt()) {
      QueueAttributes(
          attributes = attributes!!
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor =
          this.defaultConstructor ?: QueueAttributes::class.java.getDeclaredConstructor(
            Map::class.java,
            Int::class.javaPrimitiveType,
            DefaultConstructorMarker::class.java
          ).also { this.defaultConstructor = it }
      localConstructor.newInstance(
          attributes,
          mask,
          /* DefaultConstructorMarker */ null
      )
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy