org.http4k.connect.amazon.firehose.action.KotshiDeliveryStreamsJsonAdapter.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.Suppress
import kotlin.apply
import kotlin.collections.List
import kotlin.collections.setOf
import kotlin.jvm.Throws
import org.http4k.connect.amazon.model.DeliveryStreamName
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 KotshiDeliveryStreamsJsonAdapter(
moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(DeliveryStreams)") {
private val deliveryStreamNamesAdapter: JsonAdapter> = moshi.adapter(
newParameterizedType(List::class.javaObjectType, DeliveryStreamName::class.javaObjectType),
setOf(),
"DeliveryStreamNames"
)
private val options: JsonReader.Options = JsonReader.Options.of(
"DeliveryStreamNames",
"HasMoreDeliveryStreams"
)
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: DeliveryStreams?) {
if (`value` == null) {
writer.nullValue()
return
}
writer
.beginObject()
.name("DeliveryStreamNames").apply {
deliveryStreamNamesAdapter.toJson(this, `value`.DeliveryStreamNames)
}
.name("HasMoreDeliveryStreams").value(`value`.HasMoreDeliveryStreams)
.endObject()
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): DeliveryStreams? {
if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()
var deliveryStreamNames: List? = null
var hasMoreDeliveryStreams: Boolean = false
var hasMoreDeliveryStreamsIsSet: Boolean = false
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> {
deliveryStreamNames = deliveryStreamNamesAdapter.fromJson(reader)
}
1 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
hasMoreDeliveryStreams = reader.nextBoolean()
hasMoreDeliveryStreamsIsSet = true
}
}
-1 -> {
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
var errorBuilder: StringBuilder? = null
if (deliveryStreamNames == null) {
errorBuilder = errorBuilder.appendNullableError("DeliveryStreamNames")
}
if (!hasMoreDeliveryStreamsIsSet) {
errorBuilder = errorBuilder.appendNullableError("HasMoreDeliveryStreams")
}
if (errorBuilder != null) {
errorBuilder.append(" (at path ").append(reader.path).append(')')
throw JsonDataException(errorBuilder.toString())
}
return DeliveryStreams(
DeliveryStreamNames = deliveryStreamNames!!,
HasMoreDeliveryStreams = hasMoreDeliveryStreams
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy