org.http4k.connect.amazon.model.KotshiWriterVersionJsonAdapter.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 kotlin.Suppress
import kotlin.jvm.Throws
import se.ansman.kotshi.InternalKotshiApi
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 KotshiWriterVersionJsonAdapter : NamedJsonAdapter("KotshiJsonAdapter(WriterVersion)") {
private val options: JsonReader.Options = JsonReader.Options.of(
"V1",
"V2"
)
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: WriterVersion?) {
when (`value`) {
WriterVersion.V1 -> writer.value("V1")
WriterVersion.V2 -> writer.value("V2")
null -> writer.nullValue()
}
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): WriterVersion? = if (reader.peek() == JsonReader.Token.NULL) {
reader.nextNull()
} else when (reader.selectString(options)) {
0 -> WriterVersion.V1
1 -> WriterVersion.V2
else -> throw JsonDataException("""Expected one of [V1, V2] but was ${reader.nextString()} at path ${reader.path}""")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy