org.http4k.connect.amazon.systemsmanager.action.KotshiPutParameterResultJsonAdapter.kt Maven / Gradle / Ivy
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.systemsmanager.action
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.Boolean
import kotlin.Int
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 KotshiPutParameterResultJsonAdapter() :
NamedJsonAdapter("KotshiJsonAdapter(PutParameterResult)") {
private val options: JsonReader.Options = JsonReader.Options.of(
"Tier",
"Version"
)
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: PutParameterResult?) {
if (`value` == null) {
writer.nullValue()
return
}
writer
.beginObject()
.name("Tier").value(`value`.Tier)
.name("Version").value(`value`.Version)
.endObject()
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): PutParameterResult? {
if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()
var tier: String? = null
var version: Int = 0
var versionIsSet: Boolean = false
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
tier = reader.nextString()
}
}
1 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
version = reader.nextInt()
versionIsSet = true
}
}
-1 -> {
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
var errorBuilder: StringBuilder? = null
if (tier == null) {
errorBuilder = errorBuilder.appendNullableError("Tier")
}
if (!versionIsSet) {
errorBuilder = errorBuilder.appendNullableError("Version")
}
if (errorBuilder != null) {
errorBuilder.append(" (at path ").append(reader.path).append(')')
throw JsonDataException(errorBuilder.toString())
}
return PutParameterResult(
Tier = tier!!,
Version = version
)
}
}