All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.connect.amazon.model.KotshiCompressionJsonAdapter.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 KotshiCompressionJsonAdapter : NamedJsonAdapter("KotshiJsonAdapter(Compression)") {
  private val options: JsonReader.Options = JsonReader.Options.of(
      "NONE",
      "UNCOMPRESSED",
      "ZLIB",
      "SNAPPY"
  )

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: Compression?) {
    when (`value`) {
      Compression.NONE -> writer.value("NONE")
      Compression.UNCOMPRESSED -> writer.value("UNCOMPRESSED")
      Compression.ZLIB -> writer.value("ZLIB")
      Compression.SNAPPY -> writer.value("SNAPPY")
      null -> writer.nullValue()
    }
  }

  @Throws(IOException::class)
  override fun fromJson(reader: JsonReader): Compression? = if (reader.peek() == JsonReader.Token.NULL) {
    reader.nextNull()
  } else when (reader.selectString(options)) {
    0 -> Compression.NONE
    1 -> Compression.UNCOMPRESSED
    2 -> Compression.ZLIB
    3 -> Compression.SNAPPY
    else -> throw JsonDataException("""Expected one of [NONE, UNCOMPRESSED, ZLIB, SNAPPY] but was ${reader.nextString()} at path ${reader.path}""")
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy