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

com.avito.android.owner.dependency.OwnedDependencyJsonAdapter.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

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

package com.avito.android.owner.dependency

import com.avito.android.model.Owner
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.squareup.moshi.`internal`.Util
import java.lang.NullPointerException
import kotlin.Double
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Collection
import kotlin.collections.emptySet
import kotlin.text.buildString

public class OwnedDependencyJsonAdapter(
  moshi: Moshi
) : JsonAdapter() {
  private val options: JsonReader.Options = JsonReader.Options.of("moduleName", "owners", "type",
      "betweennessCentrality")

  private val stringAdapter: JsonAdapter = moshi.adapter(String::class.java, emptySet(),
      "name")

  private val collectionOfOwnerAdapter: JsonAdapter> =
      moshi.adapter(Types.newParameterizedType(Collection::class.java, Owner::class.java),
      emptySet(), "owners")

  private val typeAdapter: JsonAdapter =
      moshi.adapter(OwnedDependency.Type::class.java, emptySet(), "type")

  private val nullableDoubleAdapter: JsonAdapter =
      moshi.adapter(Double::class.javaObjectType, emptySet(), "betweennessCentrality")

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

  public override fun fromJson(reader: JsonReader): OwnedDependency {
    var name: String? = null
    var owners: Collection? = null
    var type: OwnedDependency.Type? = null
    var betweennessCentrality: Double? = null
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> name = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("name",
            "moduleName", reader)
        1 -> owners = collectionOfOwnerAdapter.fromJson(reader) ?:
            throw Util.unexpectedNull("owners", "owners", reader)
        2 -> type = typeAdapter.fromJson(reader) ?: throw Util.unexpectedNull("type", "type",
            reader)
        3 -> betweennessCentrality = nullableDoubleAdapter.fromJson(reader)
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    return OwnedDependency(
        name = name ?: throw Util.missingProperty("name", "moduleName", reader),
        owners = owners ?: throw Util.missingProperty("owners", "owners", reader),
        type = type ?: throw Util.missingProperty("type", "type", reader),
        betweennessCentrality = betweennessCentrality
    )
  }

  public override fun toJson(writer: JsonWriter, value_: OwnedDependency?): Unit {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("moduleName")
    stringAdapter.toJson(writer, value_.name)
    writer.name("owners")
    collectionOfOwnerAdapter.toJson(writer, value_.owners)
    writer.name("type")
    typeAdapter.toJson(writer, value_.type)
    writer.name("betweennessCentrality")
    nullableDoubleAdapter.toJson(writer, value_.betweennessCentrality)
    writer.endObject()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy