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

commonMain.aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.LReqContextImpl.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.LReqContext
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.MapperContext
import aws.sdk.kotlin.hll.dynamodbmapper.util.requireNull

internal data class LReqContextImpl(
    override val highLevelRequest: HReq,
    override val serializeSchema: ItemSchema,
    override val mapperContext: MapperContext,
    override val lowLevelRequest: LReq,
    override val error: Throwable?,
) : LReqContext,
    ErrorCombinable>,
    Combinable, LReq> {

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

internal operator fun  LReqContext.plus(
    lowLevelResponse: LRes,
) = LResContextImpl(
    highLevelRequest,
    serializeSchema,
    mapperContext,
    lowLevelRequest,
    lowLevelResponse,
    serializeSchema, // Use the already-resolved schema at first
    error,
)

internal fun  LReqContext.solidify() = LReqContextImpl(
    highLevelRequest,
    serializeSchema,
    mapperContext,
    requireNotNull(lowLevelRequest) { "Cannot solidify context with a null low-level request" } as LReq,
    requireNull(error) { "Cannot solidify context with a non-null error" },
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy