com.amazonaws.services.dynamodbv2.xspec.PutItemExpressionSpec Maven / Gradle / Ivy
Show all versions of aws-java-sdk-dynamodb Show documentation
/*
* Copyright 2015-2024 Amazon Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://aws.amazon.com/apache2.0
*
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and
* limitations under the License.
*/
package com.amazonaws.services.dynamodbv2.xspec;
import java.util.Collections;
import java.util.Map;
import com.amazonaws.annotation.Beta;
/**
* Expression specification for making PutItem request to Amazon DynamoDB.
*
* Even though the internal name map and value map are unmodifiable, this object
* is only as unmodifiable as the underlying values in it's value map. In turn,
* the values in the value maps are essentially provided by the users of this
* library. In other words, this object is thread-safe as long as the underlying
* values provided by the users are thread-safe.
*/
@Beta
public class PutItemExpressionSpec extends ExpressionSpec {
private final String conditionExpression;
private final Map nameMap;
private final Map valueMap;
PutItemExpressionSpec(ExpressionSpecBuilder builder) {
SubstitutionContext context = new SubstitutionContext();
this.conditionExpression = builder.buildConditionExpression(context);
final Map nameMap = context.getNameMap();
this.nameMap = nameMap == null ? null : Collections.unmodifiableMap(nameMap);
Map valueMap = context.getValueMap();
this.valueMap = valueMap == null ? null : Collections.unmodifiableMap(valueMap);
}
/**
* Returns the condition expression; or null if there is none.
*/
public String getConditionExpression() {
return conditionExpression;
}
/**
* Returns the name map which is unmodifiable; or null if there is none.
*/
@Override
public Map getNameMap() {
return nameMap;
}
/**
* Returns the value map which is unmodifiable; or null if there is none.
*/
public Map getValueMap() {
return valueMap;
}
}