org.http4k.connect.amazon.model.KotshiContentEncodingJsonAdapter.kt Maven / Gradle / Ivy
The newest version!
// 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 KotshiContentEncodingJsonAdapter : NamedJsonAdapter("KotshiJsonAdapter(ContentEncoding)") {
private val options: JsonReader.Options = JsonReader.Options.of(
"NONE",
"GZIP"
)
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: ContentEncoding?) {
when (`value`) {
ContentEncoding.NONE -> writer.value("NONE")
ContentEncoding.GZIP -> writer.value("GZIP")
null -> writer.nullValue()
}
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): ContentEncoding? = if (reader.peek() == JsonReader.Token.NULL) {
reader.nextNull()
} else when (reader.selectString(options)) {
0 -> ContentEncoding.NONE
1 -> ContentEncoding.GZIP
else -> throw JsonDataException("""Expected one of [NONE, GZIP] but was ${reader.nextString()} at path ${reader.path}""")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy