
org.http4k.connect.amazon.model.KotshiHttpEndpointCommonAttributeJsonAdapter.kt Maven / Gradle / Ivy
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.model
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import java.io.IOException
import java.lang.StringBuilder
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.Throws
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 KotshiHttpEndpointCommonAttributeJsonAdapter() : NamedJsonAdapter("KotshiJsonAdapter(HttpEndpointCommonAttribute)") {
private val options: JsonReader.Options = JsonReader.Options.of(
"AttributeName",
"AttributeValue"
)
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: HttpEndpointCommonAttribute?) {
if (`value` == null) {
writer.nullValue()
return
}
writer
.beginObject()
.name("AttributeName").value(`value`.AttributeName)
.name("AttributeValue").value(`value`.AttributeValue)
.endObject()
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): HttpEndpointCommonAttribute? {
if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()
var attributeName: String? = null
var attributeValue: String? = null
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
attributeName = reader.nextString()
}
}
1 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
attributeValue = reader.nextString()
}
}
-1 -> {
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
var errorBuilder: StringBuilder? = null
if (attributeName == null) {
errorBuilder = errorBuilder.appendNullableError("AttributeName")
}
if (attributeValue == null) {
errorBuilder = errorBuilder.appendNullableError("AttributeValue")
}
if (errorBuilder != null) {
errorBuilder.append(" (at path ").append(reader.path).append(')')
throw JsonDataException(errorBuilder.toString())
}
return HttpEndpointCommonAttribute(
AttributeName = attributeName!!,
AttributeValue = attributeValue!!
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy