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

commonMain.aws.sdk.kotlin.services.iotfleetwise.serde.StructuredMessageDocumentDeserializer.kt Maven / Gradle / Ivy

The newest version!
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.iotfleetwise.serde

import aws.sdk.kotlin.services.iotfleetwise.model.StructuredMessage
import aws.sdk.kotlin.services.iotfleetwise.model.StructuredMessageFieldNameAndDataTypePair
import aws.smithy.kotlin.runtime.serde.DeserializationException
import aws.smithy.kotlin.runtime.serde.Deserializer
import aws.smithy.kotlin.runtime.serde.SdkFieldDescriptor
import aws.smithy.kotlin.runtime.serde.SdkObjectDescriptor
import aws.smithy.kotlin.runtime.serde.SerialKind
import aws.smithy.kotlin.runtime.serde.asSdkSerializable
import aws.smithy.kotlin.runtime.serde.deserializeList
import aws.smithy.kotlin.runtime.serde.deserializeMap
import aws.smithy.kotlin.runtime.serde.deserializeStruct
import aws.smithy.kotlin.runtime.serde.field
import aws.smithy.kotlin.runtime.serde.json.IgnoreKey
import aws.smithy.kotlin.runtime.serde.json.JsonDeserializer
import aws.smithy.kotlin.runtime.serde.json.JsonSerialName
import aws.smithy.kotlin.runtime.serde.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct
import kotlin.collections.mutableListOf

internal fun deserializeStructuredMessageDocument(deserializer: Deserializer): StructuredMessage {
    var value: StructuredMessage? = null
    val PRIMITIVEMESSAGEDEFINITION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("primitiveMessageDefinition"))
    val STRUCTUREDMESSAGEDEFINITION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("structuredMessageDefinition"))
    val STRUCTUREDMESSAGELISTDEFINITION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("structuredMessageListDefinition"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        trait(IgnoreKey("__type"))
        field(PRIMITIVEMESSAGEDEFINITION_DESCRIPTOR)
        field(STRUCTUREDMESSAGEDEFINITION_DESCRIPTOR)
        field(STRUCTUREDMESSAGELISTDEFINITION_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while(true) {
            when(findNextFieldIndex()) {
                PRIMITIVEMESSAGEDEFINITION_DESCRIPTOR.index -> value = StructuredMessage.PrimitiveMessageDefinition(deserializePrimitiveMessageDefinitionDocument(deserializer))
                STRUCTUREDMESSAGEDEFINITION_DESCRIPTOR.index -> value =
                    deserializer.deserializeList(STRUCTUREDMESSAGEDEFINITION_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeStructuredMessageFieldNameAndDataTypePairDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        StructuredMessage.StructuredMessageDefinition(col0)
                    }
                STRUCTUREDMESSAGELISTDEFINITION_DESCRIPTOR.index -> value = StructuredMessage.StructuredMessageListDefinition(deserializeStructuredMessageListDefinitionDocument(deserializer))
                null -> break@loop
                else -> value = StructuredMessage.SdkUnknown.also { skipValue() }
            }
        }
    }
    return value ?: throw DeserializationException("Deserialized union value unexpectedly null: StructuredMessage")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy