org.http4k.connect.amazon.sqs.action.KotshiDeleteMessageBatchResponseJsonAdapter.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.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.Suppress
import kotlin.apply
import kotlin.collections.List
import kotlin.collections.setOf
import kotlin.jvm.Throws
import org.http4k.connect.amazon.sqs.model.BatchResultErrorEntry
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 KotshiDeleteMessageBatchResponseJsonAdapter(
moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(DeleteMessageBatchResponse)") {
private val failedAdapter: JsonAdapter?> = moshi.adapter(
newParameterizedType(List::class.javaObjectType, BatchResultErrorEntry::class.javaObjectType),
setOf(),
"Failed"
)
private val successfulAdapter: JsonAdapter> = moshi.adapter(
newParameterizedType(List::class.javaObjectType, DeleteMessageBatchResultEntry::class.javaObjectType),
setOf(),
"Successful"
)
private val options: JsonReader.Options = JsonReader.Options.of(
"Failed",
"Successful"
)
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: DeleteMessageBatchResponse?) {
if (`value` == null) {
writer.nullValue()
return
}
writer
.beginObject()
.name("Failed").apply {
failedAdapter.toJson(this, `value`.Failed)
}
.name("Successful").apply {
successfulAdapter.toJson(this, `value`.Successful)
}
.endObject()
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): DeleteMessageBatchResponse? {
if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()
var failed: List? = null
var successful: List? = null
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> {
failed = failedAdapter.fromJson(reader)
}
1 -> {
successful = successfulAdapter.fromJson(reader)
}
-1 -> {
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
var errorBuilder: StringBuilder? = null
if (successful == null) {
errorBuilder = errorBuilder.appendNullableError("Successful")
}
if (errorBuilder != null) {
errorBuilder.append(" (at path ").append(reader.path).append(')')
throw JsonDataException(errorBuilder.toString())
}
return DeleteMessageBatchResponse(
Failed = failed,
Successful = successful!!
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy