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

org.http4k.connect.amazon.model.KotshiCompressionFormatJsonAdapter.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 KotshiCompressionFormatJsonAdapter : NamedJsonAdapter("KotshiJsonAdapter(CompressionFormat)") {
  private val options: JsonReader.Options = JsonReader.Options.of(
      "UNCOMPRESSED",
      "GZIP",
      "ZIP",
      "Snappy",
      "HADOOP_SNAPPY"
  )

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: CompressionFormat?) {
    when (`value`) {
      CompressionFormat.UNCOMPRESSED -> writer.value("UNCOMPRESSED")
      CompressionFormat.GZIP -> writer.value("GZIP")
      CompressionFormat.ZIP -> writer.value("ZIP")
      CompressionFormat.Snappy -> writer.value("Snappy")
      CompressionFormat.HADOOP_SNAPPY -> writer.value("HADOOP_SNAPPY")
      null -> writer.nullValue()
    }
  }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy