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

org.http4k.connect.amazon.systemsmanager.action.KotshiPutParameterJsonAdapter.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.action

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonDataException
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.StringBuilder
import java.lang.reflect.Constructor
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.List
import kotlin.collections.setOf
import kotlin.jvm.Throws
import kotlin.jvm.Volatile
import kotlin.jvm.`internal`.DefaultConstructorMarker
import org.http4k.connect.amazon.core.model.KMSKeyId
import org.http4k.connect.amazon.core.model.Tag
import org.http4k.connect.amazon.systemsmanager.model.ParameterType
import org.http4k.connect.amazon.systemsmanager.model.SSMParameterName
import se.ansman.kotshi.InternalKotshiApi
import se.ansman.kotshi.KotshiUtils.appendNullableError
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 KotshiPutParameterJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(PutParameter)") {
  private val nameAdapter: JsonAdapter = moshi.adapter(
      SSMParameterName::class.javaObjectType,
      setOf(),
      "Name"
  )

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

  private val keyIdAdapter: JsonAdapter = moshi.adapter(
      KMSKeyId::class.javaObjectType,
      setOf(),
      "KeyId"
  )

  private val policiesAdapter: JsonAdapter?> = moshi.adapter(
      newParameterizedType(List::class.javaObjectType, String::class.javaObjectType),
      setOf(),
      "Policies"
  )

  private val tagsAdapter: JsonAdapter?> = moshi.adapter(
      newParameterizedType(List::class.javaObjectType, Tag::class.javaObjectType),
      setOf(),
      "Tags"
  )

  private val options: JsonReader.Options = JsonReader.Options.of(
      "Name",
      "Value",
      "Type",
      "KeyId",
      "Overwrite",
      "AllowedPattern",
      "DataType",
      "Description",
      "Policies",
      "Tags",
      "Tier"
  )

  @Volatile
  private var defaultConstructor: Constructor? = null

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: PutParameter?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("Name").apply {
        nameAdapter.toJson(this, `value`.Name)
      }
      .name("Value").value(`value`.Value)
      .name("Type").apply {
        typeAdapter.toJson(this, `value`.Type)
      }
      .name("KeyId").apply {
        keyIdAdapter.toJson(this, `value`.KeyId)
      }
      .name("Overwrite").value(`value`.Overwrite)
      .name("AllowedPattern").value(`value`.AllowedPattern)
      .name("DataType").value(`value`.DataType)
      .name("Description").value(`value`.Description)
      .name("Policies").apply {
        policiesAdapter.toJson(this, `value`.Policies)
      }
      .name("Tags").apply {
        tagsAdapter.toJson(this, `value`.Tags)
      }
      .name("Tier").value(`value`.Tier)
      .endObject()
  }

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

    var mask = -1
    var name: SSMParameterName? = null
    var value__: String? = null
    var type: ParameterType? = null
    var keyId: KMSKeyId? = null
    var overwrite: Boolean? = null
    var allowedPattern: String? = null
    var dataType: String? = null
    var description: String? = null
    var policies: List? = null
    var tags: List? = null
    var tier: String? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          name = nameAdapter.fromJson(reader)
        }
        1 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            value__ = reader.nextString()
          }
        }
        2 -> {
          type = typeAdapter.fromJson(reader)
        }
        3 -> {
          keyId = keyIdAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 3).inv()
          mask = mask and 0xfffffff7.toInt()
        }
        4 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            overwrite = reader.nextBoolean()
          }
          // $mask = $mask and (1 shl 4).inv()
          mask = mask and 0xffffffef.toInt()
        }
        5 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            allowedPattern = reader.nextString()
          }
          // $mask = $mask and (1 shl 5).inv()
          mask = mask and 0xffffffdf.toInt()
        }
        6 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            dataType = reader.nextString()
          }
          // $mask = $mask and (1 shl 6).inv()
          mask = mask and 0xffffffbf.toInt()
        }
        7 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            description = reader.nextString()
          }
          // $mask = $mask and (1 shl 7).inv()
          mask = mask and 0xffffff7f.toInt()
        }
        8 -> {
          policies = policiesAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 8).inv()
          mask = mask and 0xfffffeff.toInt()
        }
        9 -> {
          tags = tagsAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 9).inv()
          mask = mask and 0xfffffdff.toInt()
        }
        10 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            tier = reader.nextString()
          }
          // $mask = $mask and (1 shl 10).inv()
          mask = mask and 0xfffffbff.toInt()
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    var errorBuilder: StringBuilder? = null
    if (name == null) {
      errorBuilder = errorBuilder.appendNullableError("Name")
    }
    if (value__ == null) {
      errorBuilder = errorBuilder.appendNullableError("Value")
    }
    if (type == null) {
      errorBuilder = errorBuilder.appendNullableError("Type")
    }
    if (errorBuilder != null) {
      errorBuilder.append(" (at path ").append(reader.path).append(')')
      throw JsonDataException(errorBuilder.toString())
    }

    return if (mask == 0xfffff807.toInt()) {
      PutParameter(
          Name = name!!,
          Value = value__!!,
          Type = type!!,
          KeyId = keyId,
          Overwrite = overwrite,
          AllowedPattern = allowedPattern,
          DataType = dataType,
          Description = description,
          Policies = policies,
          Tags = tags,
          Tier = tier
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor = this.defaultConstructor ?:
          PutParameter::class.java.getDeclaredConstructor(
            SSMParameterName::class.java,
            String::class.java,
            ParameterType::class.java,
            KMSKeyId::class.java,
            Boolean::class.javaObjectType,
            String::class.java,
            String::class.java,
            String::class.java,
            List::class.java,
            List::class.java,
            String::class.java,
            Int::class.javaPrimitiveType,
            DefaultConstructorMarker::class.java
          ).also { this.defaultConstructor = it }
      localConstructor.newInstance(
          name,
          value__,
          type,
          keyId,
          overwrite,
          allowedPattern,
          dataType,
          description,
          policies,
          tags,
          tier,
          mask,
          /* DefaultConstructorMarker */ null
      )
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy