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

commonMain.aws.sdk.kotlin.services.comprehend.transform.BlockDocumentDeserializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.comprehend.transform

import aws.sdk.kotlin.services.comprehend.model.Block
import aws.sdk.kotlin.services.comprehend.model.BlockType
import aws.sdk.kotlin.services.comprehend.model.RelationshipsListItem
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 deserializeBlockDocument(deserializer: Deserializer): Block {
    val builder = Block.Builder()
    val BLOCKTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("BlockType"))
    val GEOMETRY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("Geometry"))
    val ID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Id"))
    val PAGE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("Page"))
    val RELATIONSHIPS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Relationships"))
    val TEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Text"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(BLOCKTYPE_DESCRIPTOR)
        field(GEOMETRY_DESCRIPTOR)
        field(ID_DESCRIPTOR)
        field(PAGE_DESCRIPTOR)
        field(RELATIONSHIPS_DESCRIPTOR)
        field(TEXT_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                BLOCKTYPE_DESCRIPTOR.index -> builder.blockType = deserializeString().let { BlockType.fromValue(it) }
                GEOMETRY_DESCRIPTOR.index -> builder.geometry = deserializeGeometryDocument(deserializer)
                ID_DESCRIPTOR.index -> builder.id = deserializeString()
                PAGE_DESCRIPTOR.index -> builder.page = deserializeInt()
                RELATIONSHIPS_DESCRIPTOR.index -> builder.relationships =
                    deserializer.deserializeList(RELATIONSHIPS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeRelationshipsListItemDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                TEXT_DESCRIPTOR.index -> builder.text = deserializeString()
                null -> break@loop
                else -> skipValue()
            }
        }
    }
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy