Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.http4k.connect.amazon.sqs.action.KotshiSendMessageJsonAdapter.kt Maven / Gradle / Ivy
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.amazon.sqs.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 com.squareup.moshi.Types.newParameterizedType
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.Map
import kotlin.collections.setOf
import kotlin.jvm.Throws
import kotlin.jvm.Volatile
import kotlin.jvm.`internal`.DefaultConstructorMarker
import org.http4k.connect.amazon.core.model.MessageFieldsDto
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 KotshiSendMessageJsonAdapter(
moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(SendMessage)") {
private val queueUrlAdapter: JsonAdapter = moshi.adapter(
Uri::class.javaObjectType,
setOf(),
"queueUrl"
)
private val messageAttributesAdapter: JsonAdapter?> = moshi.adapter(
newParameterizedType(Map::class.javaObjectType, String::class.javaObjectType, MessageFieldsDto::class.javaObjectType),
setOf(),
"messageAttributes"
)
private val messageSystemAttributesAdapter: JsonAdapter?> =
moshi.adapter(
newParameterizedType(Map::class.javaObjectType, String::class.javaObjectType, MessageFieldsDto::class.javaObjectType),
setOf(),
"messageSystemAttributes"
)
private val options: JsonReader.Options = JsonReader.Options.of(
"QueueUrl",
"MessageBody",
"DelaySeconds",
"MessageDeDuplicationId",
"MessageGroupId",
"MessageAttributes",
"MessageSystemAttributes"
)
@Volatile
private var defaultConstructor: Constructor? = null
@Throws(IOException::class)
override fun toJson(writer: JsonWriter, `value`: SendMessage?) {
if (`value` == null) {
writer.nullValue()
return
}
writer
.beginObject()
.name("QueueUrl").apply {
queueUrlAdapter.toJson(this, `value`.queueUrl)
}
.name("MessageBody").value(`value`.messageBody)
.name("DelaySeconds").value(`value`.delaySeconds)
.name("MessageDeDuplicationId").value(`value`.messageDeduplicationId)
.name("MessageGroupId").value(`value`.messageGroupId)
.name("MessageAttributes").apply {
messageAttributesAdapter.toJson(this, `value`.messageAttributes)
}
.name("MessageSystemAttributes").apply {
messageSystemAttributesAdapter.toJson(this, `value`.messageSystemAttributes)
}
.endObject()
}
@Throws(IOException::class)
override fun fromJson(reader: JsonReader): SendMessage? {
if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()
var mask = -1
var queueUrl: Uri? = null
var messageBody: String? = null
var delaySeconds: Int? = null
var messageDeduplicationId: String? = null
var messageGroupId: String? = null
var messageAttributes: Map? = null
var messageSystemAttributes: Map? = null
reader.beginObject()
while (reader.hasNext()) {
when (reader.selectName(options)) {
0 -> {
queueUrl = queueUrlAdapter.fromJson(reader)
}
1 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
messageBody = reader.nextString()
}
}
2 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
delaySeconds = reader.nextInt()
}
// $mask = $mask and (1 shl 2).inv()
mask = mask and 0xfffffffb.toInt()
}
3 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
messageDeduplicationId = reader.nextString()
}
// $mask = $mask and (1 shl 3).inv()
mask = mask and 0xfffffff7.toInt()
}
4 -> {
if (reader.peek() == JsonReader.Token.NULL) {
reader.skipValue()
} else {
messageGroupId = reader.nextString()
}
// $mask = $mask and (1 shl 4).inv()
mask = mask and 0xffffffef.toInt()
}
5 -> {
messageAttributes = messageAttributesAdapter.fromJson(reader)
// $mask = $mask and (1 shl 5).inv()
mask = mask and 0xffffffdf.toInt()
}
6 -> {
messageSystemAttributes = messageSystemAttributesAdapter.fromJson(reader)
// $mask = $mask and (1 shl 6).inv()
mask = mask and 0xffffffbf.toInt()
}
-1 -> {
reader.skipName()
reader.skipValue()
}
}
}
reader.endObject()
var errorBuilder: StringBuilder? = null
if (queueUrl == null) {
errorBuilder = errorBuilder.appendNullableError("queueUrl", "QueueUrl")
}
if (messageBody == null) {
errorBuilder = errorBuilder.appendNullableError("messageBody", "MessageBody")
}
if (errorBuilder != null) {
errorBuilder.append(" (at path ").append(reader.path).append(')')
throw JsonDataException(errorBuilder.toString())
}
return if (mask == 0xffffff83.toInt()) {
SendMessage(
queueUrl = queueUrl!!,
messageBody = messageBody!!,
delaySeconds = delaySeconds,
messageDeduplicationId = messageDeduplicationId,
messageGroupId = messageGroupId,
messageAttributes = messageAttributes,
messageSystemAttributes = messageSystemAttributes
)
} else {
// Reflectively invoke the synthetic defaults constructor
@Suppress("UNCHECKED_CAST")
val localConstructor: Constructor =
this.defaultConstructor ?: SendMessage::class.java.getDeclaredConstructor(
Uri::class.java,
String::class.java,
Int::class.javaObjectType,
String::class.java,
String::class.java,
Map::class.java,
Map::class.java,
Int::class.javaPrimitiveType,
DefaultConstructorMarker::class.java
).also { this.defaultConstructor = it }
localConstructor.newInstance(
queueUrl,
messageBody,
delaySeconds,
messageDeduplicationId,
messageGroupId,
messageAttributes,
messageSystemAttributes,
mask,
/* DefaultConstructorMarker */ null
)
}
}
}