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

commonMain.aws.sdk.kotlin.services.textract.serde.BlockDocumentDeserializer.kt Maven / Gradle / Ivy

There is a newer version: 1.3.76
Show newest version
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.textract.serde

import aws.sdk.kotlin.services.textract.model.Block
import aws.sdk.kotlin.services.textract.model.BlockType
import aws.sdk.kotlin.services.textract.model.EntityType
import aws.sdk.kotlin.services.textract.model.Relationship
import aws.sdk.kotlin.services.textract.model.SelectionStatus
import aws.sdk.kotlin.services.textract.model.TextType
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 COLUMNINDEX_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("ColumnIndex"))
    val COLUMNSPAN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("ColumnSpan"))
    val CONFIDENCE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Float, JsonSerialName("Confidence"))
    val ENTITYTYPES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("EntityTypes"))
    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 QUERY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("Query"))
    val RELATIONSHIPS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Relationships"))
    val ROWINDEX_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("RowIndex"))
    val ROWSPAN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("RowSpan"))
    val SELECTIONSTATUS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("SelectionStatus"))
    val TEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Text"))
    val TEXTTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("TextType"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(BLOCKTYPE_DESCRIPTOR)
        field(COLUMNINDEX_DESCRIPTOR)
        field(COLUMNSPAN_DESCRIPTOR)
        field(CONFIDENCE_DESCRIPTOR)
        field(ENTITYTYPES_DESCRIPTOR)
        field(GEOMETRY_DESCRIPTOR)
        field(ID_DESCRIPTOR)
        field(PAGE_DESCRIPTOR)
        field(QUERY_DESCRIPTOR)
        field(RELATIONSHIPS_DESCRIPTOR)
        field(ROWINDEX_DESCRIPTOR)
        field(ROWSPAN_DESCRIPTOR)
        field(SELECTIONSTATUS_DESCRIPTOR)
        field(TEXT_DESCRIPTOR)
        field(TEXTTYPE_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                BLOCKTYPE_DESCRIPTOR.index -> builder.blockType = deserializeString().let { BlockType.fromValue(it) }
                COLUMNINDEX_DESCRIPTOR.index -> builder.columnIndex = deserializeInt()
                COLUMNSPAN_DESCRIPTOR.index -> builder.columnSpan = deserializeInt()
                CONFIDENCE_DESCRIPTOR.index -> builder.confidence = deserializeFloat()
                ENTITYTYPES_DESCRIPTOR.index -> builder.entityTypes =
                    deserializer.deserializeList(ENTITYTYPES_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeString().let { EntityType.fromValue(it) } } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                GEOMETRY_DESCRIPTOR.index -> builder.geometry = deserializeGeometryDocument(deserializer)
                ID_DESCRIPTOR.index -> builder.id = deserializeString()
                PAGE_DESCRIPTOR.index -> builder.page = deserializeInt()
                QUERY_DESCRIPTOR.index -> builder.query = deserializeQueryDocument(deserializer)
                RELATIONSHIPS_DESCRIPTOR.index -> builder.relationships =
                    deserializer.deserializeList(RELATIONSHIPS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeRelationshipDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                ROWINDEX_DESCRIPTOR.index -> builder.rowIndex = deserializeInt()
                ROWSPAN_DESCRIPTOR.index -> builder.rowSpan = deserializeInt()
                SELECTIONSTATUS_DESCRIPTOR.index -> builder.selectionStatus = deserializeString().let { SelectionStatus.fromValue(it) }
                TEXT_DESCRIPTOR.index -> builder.text = deserializeString()
                TEXTTYPE_DESCRIPTOR.index -> builder.textType = deserializeString().let { TextType.fromValue(it) }
                null -> break@loop
                else -> skipValue()
            }
        }
    }
    builder.correctErrors()
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy