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

commonMain.aws.sdk.kotlin.services.iotfleetwise.serde.NodeDocumentDeserializer.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.Node
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

internal fun deserializeNodeDocument(deserializer: Deserializer): Node {
    var value: Node? = null
    val ACTUATOR_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("actuator"))
    val ATTRIBUTE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("attribute"))
    val BRANCH_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("branch"))
    val PROPERTY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("property"))
    val SENSOR_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("sensor"))
    val STRUCT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("struct"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        trait(IgnoreKey("__type"))
        field(ACTUATOR_DESCRIPTOR)
        field(ATTRIBUTE_DESCRIPTOR)
        field(BRANCH_DESCRIPTOR)
        field(PROPERTY_DESCRIPTOR)
        field(SENSOR_DESCRIPTOR)
        field(STRUCT_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while(true) {
            when(findNextFieldIndex()) {
                ACTUATOR_DESCRIPTOR.index -> value = Node.Actuator(deserializeActuatorDocument(deserializer))
                ATTRIBUTE_DESCRIPTOR.index -> value = Node.Attribute(deserializeAttributeDocument(deserializer))
                BRANCH_DESCRIPTOR.index -> value = Node.Branch(deserializeBranchDocument(deserializer))
                PROPERTY_DESCRIPTOR.index -> value = Node.Property(deserializeCustomPropertyDocument(deserializer))
                SENSOR_DESCRIPTOR.index -> value = Node.Sensor(deserializeSensorDocument(deserializer))
                STRUCT_DESCRIPTOR.index -> value = Node.Struct(deserializeCustomStructDocument(deserializer))
                null -> break@loop
                else -> value = Node.SdkUnknown.also { skipValue() }
            }
        }
    }
    return value ?: throw DeserializationException("Deserialized union value unexpectedly null: Node")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy