org.http4k.connect.amazon.model.KotshiVpcConfigurationJsonAdapter.kt Maven / Gradle / Ivy
// 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 com.squareup.moshi.Types.newParameterizedType
import java.io.IOException
import java.lang.StringBuilder
import kotlin.String
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.List
import kotlin.collections.setOf
import kotlin.jvm.Throws
import org.http4k.connect.amazon.core.model.ARN
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 KotshiVpcConfigurationJsonAdapter(
moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(VpcConfiguration)") {
private val roleARNAdapter: JsonAdapter = moshi.adapter(
ARN::class.javaObjectType,
setOf(),
"RoleARN"
)
private val securityGroupIdsAdapter: JsonAdapter> = moshi.adapter(
newParameterizedType(List::class.javaObjectType, String::class.javaObjectType),
setOf(),
"SecurityGroupIds"
)
private val subnetIdsAdapter: JsonAdapter> = moshi.adapter(
newParameterizedType(List::class.javaObjectType, String::class.javaObjectType),
setOf(),
"SubnetIds"
)
private val options: JsonReader.Options = JsonReader.Options.of(
"RoleARN",
"SecurityGroupIds",
"SubnetIds"
)
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: VpcConfiguration?) {
if (`value` == null) {
writer.nullValue()
return
}
writer
.beginObject()
.name("RoleARN").apply {
roleARNAdapter.toJson(this, `value`.RoleARN)
}
.name("SecurityGroupIds").apply {
securityGroupIdsAdapter.toJson(this, `value`.SecurityGroupIds)
}
.name("SubnetIds").apply {
subnetIdsAdapter.toJson(this, `value`.SubnetIds)
}
.endObject()
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): VpcConfiguration? {
if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()
var roleARN: ARN? = null
var securityGroupIds: List? = null
var subnetIds: List? = null
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> {
roleARN = roleARNAdapter.fromJson(reader)
}
1 -> {
securityGroupIds = securityGroupIdsAdapter.fromJson(reader)
}
2 -> {
subnetIds = subnetIdsAdapter.fromJson(reader)
}
-1 -> {
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
var errorBuilder: StringBuilder? = null
if (roleARN == null) {
errorBuilder = errorBuilder.appendNullableError("RoleARN")
}
if (securityGroupIds == null) {
errorBuilder = errorBuilder.appendNullableError("SecurityGroupIds")
}
if (subnetIds == null) {
errorBuilder = errorBuilder.appendNullableError("SubnetIds")
}
if (errorBuilder != null) {
errorBuilder.append(" (at path ").append(reader.path).append(')')
throw JsonDataException(errorBuilder.toString())
}
return VpcConfiguration(
RoleARN = roleARN!!,
SecurityGroupIds = securityGroupIds!!,
SubnetIds = subnetIds!!
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy