org.http4k.connect.amazon.model.KotshiEndpointConfigurationJsonAdapter.kt Maven / Gradle / Ivy
The newest version!
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.model
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import java.io.IOException
import java.lang.StringBuilder
import java.lang.reflect.Constructor
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.setOf
import kotlin.jvm.Throws
import kotlin.jvm.Volatile
import kotlin.jvm.`internal`.DefaultConstructorMarker
import org.http4k.core.Uri
import se.ansman.kotshi.InternalKotshiApi
import se.ansman.kotshi.KotshiUtils.appendNullableError
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 KotshiEndpointConfigurationJsonAdapter(
moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(EndpointConfiguration)") {
private val urlAdapter: JsonAdapter = moshi.adapter(
Uri::class.javaObjectType,
setOf(),
"Url"
)
private val options: JsonReader.Options = JsonReader.Options.of(
"Url",
"AccessKey",
"Name"
)
@Volatile
private var defaultConstructor: Constructor? = null
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: EndpointConfiguration?) {
if (`value` == null) {
writer.nullValue()
return
}
writer
.beginObject()
.name("Url").apply {
urlAdapter.toJson(this, `value`.Url)
}
.name("AccessKey").value(`value`.AccessKey)
.name("Name").value(`value`.Name)
.endObject()
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): EndpointConfiguration? {
if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()
var mask = -1
var url: Uri? = null
var accessKey: String? = null
var name: String? = null
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> {
url = urlAdapter.fromJson(reader)
}
1 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
accessKey = reader.nextString()
}
// $mask = $mask and (1 shl 1).inv()
mask = mask and 0xfffffffd.toInt()
}
2 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
name = reader.nextString()
}
// $mask = $mask and (1 shl 2).inv()
mask = mask and 0xfffffffb.toInt()
}
-1 -> {
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
var errorBuilder: StringBuilder? = null
if (url == null) {
errorBuilder = errorBuilder.appendNullableError("Url")
}
if (errorBuilder != null) {
errorBuilder.append(" (at path ").append(reader.path).append(')')
throw JsonDataException(errorBuilder.toString())
}
return if (mask == 0xfffffff9.toInt()) {
EndpointConfiguration(
Url = url!!,
AccessKey = accessKey,
Name = name
)
} else {
// Reflectively invoke the synthetic defaults constructor
@Suppress("UNCHECKED_CAST")
val localConstructor: Constructor =
this.defaultConstructor ?: EndpointConfiguration::class.java.getDeclaredConstructor(
Uri::class.java,
String::class.java,
String::class.java,
Int::class.javaPrimitiveType,
DefaultConstructorMarker::class.java
).also { this.defaultConstructor = it }
localConstructor.newInstance(
url,
accessKey,
name,
mask,
/* DefaultConstructorMarker */ null
)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy