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

org.http4k.connect.amazon.systemsmanager.model.KotshiParameterJsonAdapter.kt Maven / Gradle / Ivy

There is a newer version: 5.35.2.0
Show newest version
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.systemsmanager.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.Long
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.model.Timestamp
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 KotshiParameterJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(Parameter)") {
  private val aRNAdapter: JsonAdapter = moshi.adapter(
      ARN::class.javaObjectType,
      setOf(),
      "ARN"
  )

  private val nameAdapter: JsonAdapter = moshi.adapter(
      SSMParameterName::class.javaObjectType,
      setOf(),
      "Name"
  )

  private val typeAdapter: JsonAdapter = moshi.adapter(
      ParameterType::class.javaObjectType,
      setOf(),
      "Type"
  )

  private val lastModifiedDateAdapter: JsonAdapter = moshi.adapter(
      Timestamp::class.javaObjectType,
      setOf(),
      "LastModifiedDate"
  )

  private val options: JsonReader.Options = JsonReader.Options.of(
      "ARN",
      "Name",
      "Value",
      "Type",
      "DataType",
      "Version",
      "LastModifiedDate",
      "Selector",
      "SourceResult"
  )

  @Volatile
  private var defaultConstructor: Constructor? = null

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: Parameter?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("ARN").apply {
        aRNAdapter.toJson(this, `value`.ARN)
      }
      .name("Name").apply {
        nameAdapter.toJson(this, `value`.Name)
      }
      .name("Value").value(`value`.Value)
      .name("Type").apply {
        typeAdapter.toJson(this, `value`.Type)
      }
      .name("DataType").value(`value`.DataType)
      .name("Version").value(`value`.Version)
      .name("LastModifiedDate").apply {
        lastModifiedDateAdapter.toJson(this, `value`.LastModifiedDate)
      }
      .name("Selector").value(`value`.Selector)
      .name("SourceResult").value(`value`.SourceResult)
      .endObject()
  }

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

    var mask = -1
    var aRN: ARN? = null
    var name: SSMParameterName? = null
    var value__: String? = null
    var type: ParameterType? = null
    var dataType: String? = null
    var version: Long? = null
    var lastModifiedDate: Timestamp? = null
    var selector: String? = null
    var sourceResult: String? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          aRN = aRNAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 0).inv()
          mask = mask and 0xfffffffe.toInt()
        }
        1 -> {
          name = nameAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 1).inv()
          mask = mask and 0xfffffffd.toInt()
        }
        2 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            value__ = reader.nextString()
          }
          // $mask = $mask and (1 shl 2).inv()
          mask = mask and 0xfffffffb.toInt()
        }
        3 -> {
          type = typeAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 3).inv()
          mask = mask and 0xfffffff7.toInt()
        }
        4 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            dataType = reader.nextString()
          }
          // $mask = $mask and (1 shl 4).inv()
          mask = mask and 0xffffffef.toInt()
        }
        5 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            version = reader.nextLong()
          }
          // $mask = $mask and (1 shl 5).inv()
          mask = mask and 0xffffffdf.toInt()
        }
        6 -> {
          lastModifiedDate = lastModifiedDateAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 6).inv()
          mask = mask and 0xffffffbf.toInt()
        }
        7 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            selector = reader.nextString()
          }
          // $mask = $mask and (1 shl 7).inv()
          mask = mask and 0xffffff7f.toInt()
        }
        8 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            sourceResult = reader.nextString()
          }
          // $mask = $mask and (1 shl 8).inv()
          mask = mask and 0xfffffeff.toInt()
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    return if (mask == 0xfffffe00.toInt()) {
      Parameter(
          ARN = aRN,
          Name = name,
          Value = value__,
          Type = type,
          DataType = dataType,
          Version = version,
          LastModifiedDate = lastModifiedDate,
          Selector = selector,
          SourceResult = sourceResult
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor = this.defaultConstructor ?:
          Parameter::class.java.getDeclaredConstructor(
            ARN::class.java,
            SSMParameterName::class.java,
            String::class.java,
            ParameterType::class.java,
            String::class.java,
            Long::class.javaObjectType,
            Timestamp::class.java,
            String::class.java,
            String::class.java,
            Int::class.javaPrimitiveType,
            DefaultConstructorMarker::class.java
          ).also { this.defaultConstructor = it }
      localConstructor.newInstance(
          aRN,
          name,
          value__,
          type,
          dataType,
          version,
          lastModifiedDate,
          selector,
          sourceResult,
          mask,
          /* DefaultConstructorMarker */ null
      )
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy