commonMain.aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.LResContextImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dynamodb-mapper-jvm Show documentation
Show all versions of dynamodb-mapper-jvm Show documentation
High level DynamoDbMapper client
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal
import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.DeserializeInput
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.LResContext
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.MapperContext
import aws.sdk.kotlin.hll.dynamodbmapper.util.requireNull
internal data class LResContextImpl(
override val highLevelRequest: HReq,
override val serializeSchema: ItemSchema,
override val mapperContext: MapperContext,
override val lowLevelRequest: LReq,
override val lowLevelResponse: LRes,
override val deserializeSchema: ItemSchema,
override val error: Throwable?,
) : LResContext,
ErrorCombinable>,
Combinable, DeserializeInput> {
override fun plus(e: Throwable?) = copy(error = e.suppressing(error))
override fun plus(value: DeserializeInput) = copy(
lowLevelResponse = value.lowLevelResponse,
deserializeSchema = value.deserializeSchema,
)
}
internal operator fun LResContext.plus(
highLevelResponse: HRes,
) = HResContextImpl(
highLevelRequest,
serializeSchema,
mapperContext,
lowLevelRequest,
lowLevelResponse,
deserializeSchema,
highLevelResponse,
error,
)
internal fun LResContext.solidify() = LResContextImpl(
highLevelRequest,
serializeSchema,
mapperContext,
lowLevelRequest,
requireNotNull(lowLevelResponse) { "Cannot solidify context with a null low-level response" } as LRes,
deserializeSchema,
requireNull(error) { "Cannot solidify context with a non-null error" },
)