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

org.http4k.connect.amazon.firehose.action.KotshiBatchResultJsonAdapter.kt Maven / Gradle / Ivy

The newest version!
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.firehose.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 kotlin.Boolean
import kotlin.Int
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.List
import kotlin.collections.setOf
import kotlin.jvm.Throws
import org.http4k.connect.amazon.model.RequestResponses
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 KotshiBatchResultJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(BatchResult)") {
  private val requestResponsesAdapter: JsonAdapter?> = moshi.adapter(
      newParameterizedType(List::class.javaObjectType, RequestResponses::class.javaObjectType),
      setOf(),
      "RequestResponses"
  )

  private val options: JsonReader.Options = JsonReader.Options.of(
      "Encrypted",
      "FailedPutCount",
      "RequestResponses"
  )

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: BatchResult?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("Encrypted").value(`value`.Encrypted)
      .name("FailedPutCount").value(`value`.FailedPutCount)
      .name("RequestResponses").apply {
        requestResponsesAdapter.toJson(this, `value`.RequestResponses)
      }
      .endObject()
  }

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

    var encrypted: Boolean = false
    var encryptedIsSet: Boolean = false
    var failedPutCount: Int = 0
    var failedPutCountIsSet: Boolean = false
    var requestResponses: List? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            encrypted = reader.nextBoolean()
            encryptedIsSet = true
          }
        }
        1 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            failedPutCount = reader.nextInt()
            failedPutCountIsSet = true
          }
        }
        2 -> {
          requestResponses = requestResponsesAdapter.fromJson(reader)
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    var errorBuilder: StringBuilder? = null
    if (!encryptedIsSet) {
      errorBuilder = errorBuilder.appendNullableError("Encrypted")
    }
    if (!failedPutCountIsSet) {
      errorBuilder = errorBuilder.appendNullableError("FailedPutCount")
    }
    if (errorBuilder != null) {
      errorBuilder.append(" (at path ").append(reader.path).append(')')
      throw JsonDataException(errorBuilder.toString())
    }

    return BatchResult(
        Encrypted = encrypted,
        FailedPutCount = failedPutCount,
        RequestResponses = requestResponses
    )
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy