org.http4k.connect.amazon.systemsmanager.action.KotshiGetParameterJsonAdapter.kt Maven / Gradle / Ivy
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.systemsmanager.action
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.Boolean
import kotlin.Int
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.connect.amazon.systemsmanager.model.SSMParameterName
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 KotshiGetParameterJsonAdapter(
moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(GetParameter)") {
private val nameAdapter: JsonAdapter = moshi.adapter(
SSMParameterName::class.javaObjectType,
setOf(),
"Name"
)
private val options: JsonReader.Options = JsonReader.Options.of(
"Name",
"WithDecryption"
)
@Volatile
private var defaultConstructor: Constructor? = null
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: GetParameter?) {
if (`value` == null) {
writer.nullValue()
return
}
writer
.beginObject()
.name("Name").apply {
nameAdapter.toJson(this, `value`.Name)
}
.name("WithDecryption").value(`value`.WithDecryption)
.endObject()
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): GetParameter? {
if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()
var mask = -1
var name: SSMParameterName? = null
var withDecryption: Boolean? = null
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> {
name = nameAdapter.fromJson(reader)
}
1 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
withDecryption = reader.nextBoolean()
}
// $mask = $mask and (1 shl 1).inv()
mask = mask and 0xfffffffd.toInt()
}
-1 -> {
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
var errorBuilder: StringBuilder? = null
if (name == null) {
errorBuilder = errorBuilder.appendNullableError("Name")
}
if (errorBuilder != null) {
errorBuilder.append(" (at path ").append(reader.path).append(')')
throw JsonDataException(errorBuilder.toString())
}
return if (mask == 0xfffffffd.toInt()) {
GetParameter(
Name = name!!,
WithDecryption = withDecryption
)
} else {
// Reflectively invoke the synthetic defaults constructor
@Suppress("UNCHECKED_CAST")
val localConstructor: Constructor = this.defaultConstructor ?:
GetParameter::class.java.getDeclaredConstructor(
SSMParameterName::class.java,
Boolean::class.javaObjectType,
Int::class.javaPrimitiveType,
DefaultConstructorMarker::class.java
).also { this.defaultConstructor = it }
localConstructor.newInstance(
name,
withDecryption,
mask,
/* DefaultConstructorMarker */ null
)
}
}
}