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

org.http4k.connect.amazon.model.KotshiKinesisStreamSourceConfigurationJsonAdapter.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.JsonDataException
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import java.io.IOException
import java.lang.StringBuilder
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.setOf
import kotlin.jvm.Throws
import org.http4k.connect.amazon.core.model.ARN
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 KotshiKinesisStreamSourceConfigurationJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(KinesisStreamSourceConfiguration)") {
  private val kinesisStreamARNAdapter: JsonAdapter = moshi.adapter(
      ARN::class.javaObjectType,
      setOf(),
      "KinesisStreamARN"
  )

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

  private val options: JsonReader.Options = JsonReader.Options.of(
      "KinesisStreamARN",
      "RoleARN"
  )

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: KinesisStreamSourceConfiguration?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("KinesisStreamARN").apply {
        kinesisStreamARNAdapter.toJson(this, `value`.KinesisStreamARN)
      }
      .name("RoleARN").apply {
        roleARNAdapter.toJson(this, `value`.RoleARN)
      }
      .endObject()
  }

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

    var kinesisStreamARN: ARN? = null
    var roleARN: ARN? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          kinesisStreamARN = kinesisStreamARNAdapter.fromJson(reader)
        }
        1 -> {
          roleARN = roleARNAdapter.fromJson(reader)
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    var errorBuilder: StringBuilder? = null
    if (kinesisStreamARN == null) {
      errorBuilder = errorBuilder.appendNullableError("KinesisStreamARN")
    }
    if (roleARN == null) {
      errorBuilder = errorBuilder.appendNullableError("RoleARN")
    }
    if (errorBuilder != null) {
      errorBuilder.append(" (at path ").append(reader.path).append(')')
      throw JsonDataException(errorBuilder.toString())
    }

    return KinesisStreamSourceConfiguration(
        KinesisStreamARN = kinesisStreamARN!!,
        RoleARN = roleARN!!
    )
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy