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

commonMain.aws.sdk.kotlin.services.cloudwatch.serde.DatapointValueMapShapeDeserializer.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.cloudwatch.serde

import aws.smithy.kotlin.runtime.serde.DeserializationException
import aws.smithy.kotlin.runtime.serde.getOrDeserializeErr
import aws.smithy.kotlin.runtime.serde.parseDouble
import aws.smithy.kotlin.runtime.serde.xml.XmlTagReader
import aws.smithy.kotlin.runtime.serde.xml.tryData
import kotlin.collections.MutableMap

internal fun deserializeDatapointValueMapShape(reader: XmlTagReader): Map {
    val result = mutableMapOf()
    loop@while (true) {
        val curr = reader.nextTag() ?: break@loop
        when (curr.tagName) {
            "entry" -> {
                deserializeDatapointValueMapEntry(result, curr)
            }
            else -> {}
        }
        curr.drop()
    }
    return result
}

internal fun deserializeDatapointValueMapEntry(dest: MutableMap, reader: XmlTagReader) {
    var key: String? = null
    var value: Double? = null
    loop@while (true) {
        val curr = reader.nextTag() ?: break@loop
        when (curr.tagName) {
            "key" -> key = curr.tryData()
                .getOrDeserializeErr { "expected (string: `com.amazonaws.cloudwatch#ExtendedStatistic`)" }
            "value" -> value = curr.tryData()
                .parseDouble()
                .getOrDeserializeErr { "expected (double: `com.amazonaws.cloudwatch#DatapointValue`)" }
            else -> {}
        }
        curr.drop()
    }
    if (key == null) throw DeserializationException("missing key map entry")
    if (value == null) throw DeserializationException("missing value map entry")
    dest[key] = value
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy