Search in sources :

Example 1 with Either

use of software.amazon.awssdk.utils.Either in project aws-sdk-java-v2 by aws.

the class UpdateItemOperation method generateConditionExpressionIfExist.

/**
 * Retrieves the ConditionExpression from extensions if existing, and retrieves the ConditionExpression from the request
 * if existing. If both exist, they are merged.
 */
private Expression generateConditionExpressionIfExist(WriteModification transformation, Either<UpdateItemEnhancedRequest<T>, TransactUpdateItemEnhancedRequest<T>> request) {
    Expression conditionExpression = null;
    if (transformation != null && transformation.additionalConditionalExpression() != null) {
        conditionExpression = transformation.additionalConditionalExpression();
    }
    Expression operationConditionExpression = request.map(r -> Optional.ofNullable(r.conditionExpression()), r -> Optional.ofNullable(r.conditionExpression())).orElse(null);
    if (operationConditionExpression != null) {
        conditionExpression = operationConditionExpression.and(conditionExpression);
    }
    return conditionExpression;
}
Also used : TransactWriteItem(software.amazon.awssdk.services.dynamodb.model.TransactWriteItem) UpdateItemRequest(software.amazon.awssdk.services.dynamodb.model.UpdateItemRequest) DynamoDbAsyncClient(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient) TransactUpdateItemEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.TransactUpdateItemEnhancedRequest) CompletableFuture(java.util.concurrent.CompletableFuture) Expression(software.amazon.awssdk.enhanced.dynamodb.Expression) Function(java.util.function.Function) Update(software.amazon.awssdk.services.dynamodb.model.Update) UpdateExpression(software.amazon.awssdk.enhanced.dynamodb.update.UpdateExpression) CollectionUtils(software.amazon.awssdk.utils.CollectionUtils) Map(java.util.Map) CollectionUtils.filterMap(software.amazon.awssdk.utils.CollectionUtils.filterMap) UpdateExpressionConverter(software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionConverter) UpdateExpressionUtils.operationExpression(software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionUtils.operationExpression) DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) EnhancedClientUtils.readAndTransformSingleItem(software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.readAndTransformSingleItem) Collection(java.util.Collection) TableSchema(software.amazon.awssdk.enhanced.dynamodb.TableSchema) WriteModification(software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification) Either(software.amazon.awssdk.utils.Either) UpdateItemEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedRequest) DefaultDynamoDbExtensionContext(software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext) List(java.util.List) DynamoDbEnhancedClientExtension(software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension) TableMetadata(software.amazon.awssdk.enhanced.dynamodb.TableMetadata) UpdateItemEnhancedResponse(software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedResponse) OperationContext(software.amazon.awssdk.enhanced.dynamodb.OperationContext) AttributeValue(software.amazon.awssdk.services.dynamodb.model.AttributeValue) Optional(java.util.Optional) SdkInternalApi(software.amazon.awssdk.annotations.SdkInternalApi) ReturnValue(software.amazon.awssdk.services.dynamodb.model.ReturnValue) UpdateItemResponse(software.amazon.awssdk.services.dynamodb.model.UpdateItemResponse) Expression(software.amazon.awssdk.enhanced.dynamodb.Expression) UpdateExpression(software.amazon.awssdk.enhanced.dynamodb.update.UpdateExpression) UpdateExpressionUtils.operationExpression(software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionUtils.operationExpression)

Aggregations

Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Function (java.util.function.Function)1 SdkInternalApi (software.amazon.awssdk.annotations.SdkInternalApi)1 DynamoDbEnhancedClientExtension (software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension)1 Expression (software.amazon.awssdk.enhanced.dynamodb.Expression)1 OperationContext (software.amazon.awssdk.enhanced.dynamodb.OperationContext)1 TableMetadata (software.amazon.awssdk.enhanced.dynamodb.TableMetadata)1 TableSchema (software.amazon.awssdk.enhanced.dynamodb.TableSchema)1 WriteModification (software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification)1 EnhancedClientUtils.readAndTransformSingleItem (software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.readAndTransformSingleItem)1 DefaultDynamoDbExtensionContext (software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext)1 UpdateExpressionConverter (software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionConverter)1 UpdateExpressionUtils.operationExpression (software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionUtils.operationExpression)1 TransactUpdateItemEnhancedRequest (software.amazon.awssdk.enhanced.dynamodb.model.TransactUpdateItemEnhancedRequest)1 UpdateItemEnhancedRequest (software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedRequest)1 UpdateItemEnhancedResponse (software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedResponse)1