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

app.cash.sqldelight.dialects.postgresql.ide.PostgresConnectionManager_ConnectionSettingsJsonAdapter.kt Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show 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 app.cash.sqldelight.dialects.postgresql.ide

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.`internal`.Util
import java.lang.NullPointerException
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.emptySet
import kotlin.text.buildString

internal class PostgresConnectionManager_ConnectionSettingsJsonAdapter(
  moshi: Moshi,
) : JsonAdapter() {
  private val options: JsonReader.Options = JsonReader.Options.of("host", "port", "databaseName",
      "username", "password")

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

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

  public override fun toString(): String = buildString(66) {
      append("GeneratedJsonAdapter(").append("PostgresConnectionManager.ConnectionSettings").append(')')
      }

  public override fun fromJson(reader: JsonReader): PostgresConnectionManager.ConnectionSettings {
    var host: String? = null
    var port: String? = null
    var databaseName: String? = null
    var username: String? = null
    var password: String? = null
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> host = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("host", "host",
            reader)
        1 -> port = stringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("port", "port",
            reader)
        2 -> databaseName = nullableStringAdapter.fromJson(reader)
        3 -> username = nullableStringAdapter.fromJson(reader)
        4 -> password = nullableStringAdapter.fromJson(reader)
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    return PostgresConnectionManager.ConnectionSettings(
        host = host ?: throw Util.missingProperty("host", "host", reader),
        port = port ?: throw Util.missingProperty("port", "port", reader),
        databaseName = databaseName,
        username = username,
        password = password
    )
  }

  public override fun toJson(writer: JsonWriter,
      value_: PostgresConnectionManager.ConnectionSettings?): Unit {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("host")
    stringAdapter.toJson(writer, value_.host)
    writer.name("port")
    stringAdapter.toJson(writer, value_.port)
    writer.name("databaseName")
    nullableStringAdapter.toJson(writer, value_.databaseName)
    writer.name("username")
    nullableStringAdapter.toJson(writer, value_.username)
    writer.name("password")
    nullableStringAdapter.toJson(writer, value_.password)
    writer.endObject()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy