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

commonMain.aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.HResContextImpl.kt Maven / Gradle / Ivy

There is a newer version: 1.3.73-beta
Show newest version
/*
 * 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.HResContext
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.MapperContext
import aws.sdk.kotlin.hll.dynamodbmapper.util.requireNull

internal data class HResContextImpl(
    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 highLevelResponse: HRes,
    override val error: Throwable?,
) : HResContext,
    ErrorCombinable>,
    Combinable, HRes> {

    override fun plus(e: Throwable?) = copy(error = e.suppressing(error))
    override fun plus(value: HRes) = copy(highLevelResponse = value)
}

internal fun  HResContextImpl.solidify() =
    HResContextImpl(
        highLevelRequest,
        serializeSchema,
        mapperContext,
        lowLevelRequest,
        lowLevelResponse,
        deserializeSchema,
        requireNotNull(highLevelResponse) { "Cannot solidify context with a null high-level response" } as HRes,
        requireNull(error) { "Cannot solidify context with a non-null error" },
    )




© 2015 - 2024 Weber Informatics LLC | Privacy Policy