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

tech.carpentum.sdk.payment.internal.generated.model.ForexRateJsonJsonAdapter.kt Maven / Gradle / Ivy

The newest version!
// Code generated by moshi-kotlin-codegen. Do not edit.
@file:Suppress("DEPRECATION", "unused", "UNUSED_PARAMETER", "ClassName", "REDUNDANT_PROJECTION",
    "RedundantExplicitType", "LocalVariableName", "RedundantVisibilityModifier",
    "PLATFORM_CLASS_MAPPED_TO_KOTLIN", "IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION")

package tech.carpentum.sdk.payment.`internal`.generated.model

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import java.lang.NullPointerException
import java.math.BigDecimal
import java.time.OffsetDateTime
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.emptySet
import kotlin.text.buildString
import tech.carpentum.sdk.payment.model.CurrencyCode

public class ForexRateJsonJsonAdapter(
  moshi: Moshi,
) : JsonAdapter() {
  private val options: JsonReader.Options = JsonReader.Options.of("baseCurrencyCode",
      "quoteCurrencyCode", "buyRate", "sellRate", "validUpTo")

  private val nullableCurrencyCodeAdapter: JsonAdapter =
      moshi.adapter(CurrencyCode::class.java, emptySet(), "baseCurrencyCode")

  private val nullableBigDecimalAdapter: JsonAdapter =
      moshi.adapter(BigDecimal::class.java, emptySet(), "buyRate")

  private val nullableOffsetDateTimeAdapter: JsonAdapter =
      moshi.adapter(OffsetDateTime::class.java, emptySet(), "validUpTo")

  public override fun toString(): String = buildString(35) {
      append("GeneratedJsonAdapter(").append("ForexRateJson").append(')') }

  public override fun fromJson(reader: JsonReader): ForexRateJson {
    var baseCurrencyCode: CurrencyCode? = null
    var baseCurrencyCodeSet: Boolean = false
    var quoteCurrencyCode: CurrencyCode? = null
    var quoteCurrencyCodeSet: Boolean = false
    var buyRate: BigDecimal? = null
    var buyRateSet: Boolean = false
    var sellRate: BigDecimal? = null
    var sellRateSet: Boolean = false
    var validUpTo: OffsetDateTime? = null
    var validUpToSet: Boolean = false
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          baseCurrencyCode = nullableCurrencyCodeAdapter.fromJson(reader)
          baseCurrencyCodeSet = true
        }
        1 -> {
          quoteCurrencyCode = nullableCurrencyCodeAdapter.fromJson(reader)
          quoteCurrencyCodeSet = true
        }
        2 -> {
          buyRate = nullableBigDecimalAdapter.fromJson(reader)
          buyRateSet = true
        }
        3 -> {
          sellRate = nullableBigDecimalAdapter.fromJson(reader)
          sellRateSet = true
        }
        4 -> {
          validUpTo = nullableOffsetDateTimeAdapter.fromJson(reader)
          validUpToSet = true
        }
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    val result: ForexRateJson
    result = ForexRateJson(
    )
    if (baseCurrencyCodeSet) {
      result.baseCurrencyCode = baseCurrencyCode
    }
    if (quoteCurrencyCodeSet) {
      result.quoteCurrencyCode = quoteCurrencyCode
    }
    if (buyRateSet) {
      result.buyRate = buyRate
    }
    if (sellRateSet) {
      result.sellRate = sellRate
    }
    if (validUpToSet) {
      result.validUpTo = validUpTo
    }
    return result
  }

  public override fun toJson(writer: JsonWriter, value_: ForexRateJson?): Unit {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("baseCurrencyCode")
    nullableCurrencyCodeAdapter.toJson(writer, value_.baseCurrencyCode)
    writer.name("quoteCurrencyCode")
    nullableCurrencyCodeAdapter.toJson(writer, value_.quoteCurrencyCode)
    writer.name("buyRate")
    nullableBigDecimalAdapter.toJson(writer, value_.buyRate)
    writer.name("sellRate")
    nullableBigDecimalAdapter.toJson(writer, value_.sellRate)
    writer.name("validUpTo")
    nullableOffsetDateTimeAdapter.toJson(writer, value_.validUpTo)
    writer.endObject()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy