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

commonMain.aws.sdk.kotlin.services.comprehendmedical.serde.RxNormAttributeDocumentDeserializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.comprehendmedical.serde

import aws.sdk.kotlin.services.comprehendmedical.model.RxNormAttribute
import aws.sdk.kotlin.services.comprehendmedical.model.RxNormAttributeType
import aws.sdk.kotlin.services.comprehendmedical.model.RxNormTrait
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.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 deserializeRxNormAttributeDocument(deserializer: Deserializer): RxNormAttribute {
    val builder = RxNormAttribute.Builder()
    val BEGINOFFSET_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("BeginOffset"))
    val ENDOFFSET_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("EndOffset"))
    val ID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("Id"))
    val RELATIONSHIPSCORE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Float, JsonSerialName("RelationshipScore"))
    val SCORE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Float, JsonSerialName("Score"))
    val TEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Text"))
    val TRAITS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Traits"))
    val TYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Type"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(BEGINOFFSET_DESCRIPTOR)
        field(ENDOFFSET_DESCRIPTOR)
        field(ID_DESCRIPTOR)
        field(RELATIONSHIPSCORE_DESCRIPTOR)
        field(SCORE_DESCRIPTOR)
        field(TEXT_DESCRIPTOR)
        field(TRAITS_DESCRIPTOR)
        field(TYPE_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                BEGINOFFSET_DESCRIPTOR.index -> builder.beginOffset = deserializeInt()
                ENDOFFSET_DESCRIPTOR.index -> builder.endOffset = deserializeInt()
                ID_DESCRIPTOR.index -> builder.id = deserializeInt()
                RELATIONSHIPSCORE_DESCRIPTOR.index -> builder.relationshipScore = deserializeFloat()
                SCORE_DESCRIPTOR.index -> builder.score = deserializeFloat()
                TEXT_DESCRIPTOR.index -> builder.text = deserializeString()
                TRAITS_DESCRIPTOR.index -> builder.traits =
                    deserializer.deserializeList(TRAITS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeRxNormTraitDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                TYPE_DESCRIPTOR.index -> builder.type = deserializeString().let { RxNormAttributeType.fromValue(it) }
                null -> break@loop
                else -> skipValue()
            }
        }
    }
    builder.correctErrors()
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy