expressionAttributeValues;
private UpdateItemRequest(BuilderImpl builder) {
super(builder);
this.tableName = builder.tableName;
this.key = builder.key;
this.attributeUpdates = builder.attributeUpdates;
this.expected = builder.expected;
this.conditionalOperator = builder.conditionalOperator;
this.returnValues = builder.returnValues;
this.returnConsumedCapacity = builder.returnConsumedCapacity;
this.returnItemCollectionMetrics = builder.returnItemCollectionMetrics;
this.updateExpression = builder.updateExpression;
this.conditionExpression = builder.conditionExpression;
this.expressionAttributeNames = builder.expressionAttributeNames;
this.expressionAttributeValues = builder.expressionAttributeValues;
}
/**
*
* The name of the table containing the item to update.
*
*
* @return The name of the table containing the item to update.
*/
public final String tableName() {
return tableName;
}
/**
* For responses, this returns true if the service returned a value for the Key property. This DOES NOT check that
* the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is useful
* because the SDK will never return a null collection or map, but you may need to differentiate between the service
* returning nothing (or null) and the service returning an empty collection or map. For requests, this returns true
* if a value for the property was specified in the request builder, and false if a value was not specified.
*/
public final boolean hasKey() {
return key != null && !(key instanceof SdkAutoConstructMap);
}
/**
*
* The primary key of the item to be updated. Each element consists of an attribute name and a value for that
* attribute.
*
*
* For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only
* need to provide a value for the partition key. For a composite primary key, you must provide values for both the
* partition key and the sort key.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasKey} method.
*
*
* @return The primary key of the item to be updated. Each element consists of an attribute name and a value for
* that attribute.
*
* For the primary key, you must provide all of the attributes. For example, with a simple primary key, you
* only need to provide a value for the partition key. For a composite primary key, you must provide values
* for both the partition key and the sort key.
*/
public final Map key() {
return key;
}
/**
* For responses, this returns true if the service returned a value for the AttributeUpdates property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasAttributeUpdates() {
return attributeUpdates != null && !(attributeUpdates instanceof SdkAutoConstructMap);
}
/**
*
* This is a legacy parameter. Use UpdateExpression
instead. For more information, see AttributeUpdates in the Amazon DynamoDB Developer Guide .
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasAttributeUpdates} method.
*
*
* @return This is a legacy parameter. Use UpdateExpression
instead. For more information, see AttributeUpdates in the Amazon DynamoDB Developer Guide .
*/
public final Map attributeUpdates() {
return attributeUpdates;
}
/**
* For responses, this returns true if the service returned a value for the Expected property. This DOES NOT check
* that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is
* useful because the SDK will never return a null collection or map, but you may need to differentiate between the
* service returning nothing (or null) and the service returning an empty collection or map. For requests, this
* returns true if a value for the property was specified in the request builder, and false if a value was not
* specified.
*/
public final boolean hasExpected() {
return expected != null && !(expected instanceof SdkAutoConstructMap);
}
/**
*
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see Expected in the Amazon DynamoDB Developer Guide .
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasExpected} method.
*
*
* @return This is a legacy parameter. Use ConditionExpression
instead. For more information, see Expected in the Amazon DynamoDB Developer Guide .
*/
public final Map expected() {
return expected;
}
/**
*
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #conditionalOperator} will return {@link ConditionalOperator#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #conditionalOperatorAsString}.
*
*
* @return This is a legacy parameter. Use ConditionExpression
instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
* @see ConditionalOperator
*/
public final ConditionalOperator conditionalOperator() {
return ConditionalOperator.fromValue(conditionalOperator);
}
/**
*
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #conditionalOperator} will return {@link ConditionalOperator#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #conditionalOperatorAsString}.
*
*
* @return This is a legacy parameter. Use ConditionExpression
instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
* @see ConditionalOperator
*/
public final String conditionalOperatorAsString() {
return conditionalOperator;
}
/**
*
* Use ReturnValues
if you want to get the item attributes as they appear before or after they are
* updated. For UpdateItem
, the valid values are:
*
*
*
*
* NONE
- If ReturnValues
is not specified, or if its value is NONE
, then
* nothing is returned. (This setting is the default for ReturnValues
.)
*
*
*
*
* ALL_OLD
- Returns all of the attributes of the item, as they appeared before the UpdateItem
* operation.
*
*
*
*
* UPDATED_OLD
- Returns only the updated attributes, as they appeared before the UpdateItem operation.
*
*
*
*
* ALL_NEW
- Returns all of the attributes of the item, as they appear after the UpdateItem operation.
*
*
*
*
* UPDATED_NEW
- Returns only the updated attributes, as they appear after the UpdateItem operation.
*
*
*
*
* There is no additional cost associated with requesting a return value aside from the small network and processing
* overhead of receiving a larger response. No read capacity units are consumed.
*
*
* The values returned are strongly consistent.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #returnValues} will
* return {@link ReturnValue#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #returnValuesAsString}.
*
*
* @return Use ReturnValues
if you want to get the item attributes as they appear before or after they
* are updated. For UpdateItem
, the valid values are:
*
*
*
* NONE
- If ReturnValues
is not specified, or if its value is NONE
,
* then nothing is returned. (This setting is the default for ReturnValues
.)
*
*
*
*
* ALL_OLD
- Returns all of the attributes of the item, as they appeared before the UpdateItem
* operation.
*
*
*
*
* UPDATED_OLD
- Returns only the updated attributes, as they appeared before the UpdateItem
* operation.
*
*
*
*
* ALL_NEW
- Returns all of the attributes of the item, as they appear after the UpdateItem
* operation.
*
*
*
*
* UPDATED_NEW
- Returns only the updated attributes, as they appear after the UpdateItem
* operation.
*
*
*
*
* There is no additional cost associated with requesting a return value aside from the small network and
* processing overhead of receiving a larger response. No read capacity units are consumed.
*
*
* The values returned are strongly consistent.
* @see ReturnValue
*/
public final ReturnValue returnValues() {
return ReturnValue.fromValue(returnValues);
}
/**
*
* Use ReturnValues
if you want to get the item attributes as they appear before or after they are
* updated. For UpdateItem
, the valid values are:
*
*
*
*
* NONE
- If ReturnValues
is not specified, or if its value is NONE
, then
* nothing is returned. (This setting is the default for ReturnValues
.)
*
*
*
*
* ALL_OLD
- Returns all of the attributes of the item, as they appeared before the UpdateItem
* operation.
*
*
*
*
* UPDATED_OLD
- Returns only the updated attributes, as they appeared before the UpdateItem operation.
*
*
*
*
* ALL_NEW
- Returns all of the attributes of the item, as they appear after the UpdateItem operation.
*
*
*
*
* UPDATED_NEW
- Returns only the updated attributes, as they appear after the UpdateItem operation.
*
*
*
*
* There is no additional cost associated with requesting a return value aside from the small network and processing
* overhead of receiving a larger response. No read capacity units are consumed.
*
*
* The values returned are strongly consistent.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #returnValues} will
* return {@link ReturnValue#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #returnValuesAsString}.
*
*
* @return Use ReturnValues
if you want to get the item attributes as they appear before or after they
* are updated. For UpdateItem
, the valid values are:
*
*
*
* NONE
- If ReturnValues
is not specified, or if its value is NONE
,
* then nothing is returned. (This setting is the default for ReturnValues
.)
*
*
*
*
* ALL_OLD
- Returns all of the attributes of the item, as they appeared before the UpdateItem
* operation.
*
*
*
*
* UPDATED_OLD
- Returns only the updated attributes, as they appeared before the UpdateItem
* operation.
*
*
*
*
* ALL_NEW
- Returns all of the attributes of the item, as they appear after the UpdateItem
* operation.
*
*
*
*
* UPDATED_NEW
- Returns only the updated attributes, as they appear after the UpdateItem
* operation.
*
*
*
*
* There is no additional cost associated with requesting a return value aside from the small network and
* processing overhead of receiving a larger response. No read capacity units are consumed.
*
*
* The values returned are strongly consistent.
* @see ReturnValue
*/
public final String returnValuesAsString() {
return returnValues;
}
/**
* Returns the value of the ReturnConsumedCapacity property for this object.
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnConsumedCapacity} will return {@link ReturnConsumedCapacity#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #returnConsumedCapacityAsString}.
*
*
* @return The value of the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
*/
public final ReturnConsumedCapacity returnConsumedCapacity() {
return ReturnConsumedCapacity.fromValue(returnConsumedCapacity);
}
/**
* Returns the value of the ReturnConsumedCapacity property for this object.
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnConsumedCapacity} will return {@link ReturnConsumedCapacity#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #returnConsumedCapacityAsString}.
*
*
* @return The value of the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
*/
public final String returnConsumedCapacityAsString() {
return returnConsumedCapacity;
}
/**
*
* Determines whether item collection metrics are returned. If set to SIZE
, the response includes
* statistics about item collections, if any, that were modified during the operation are returned in the response.
* If set to NONE
(the default), no statistics are returned.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnItemCollectionMetrics} will return {@link ReturnItemCollectionMetrics#UNKNOWN_TO_SDK_VERSION}. The
* raw value returned by the service is available from {@link #returnItemCollectionMetricsAsString}.
*
*
* @return Determines whether item collection metrics are returned. If set to SIZE
, the response
* includes statistics about item collections, if any, that were modified during the operation are returned
* in the response. If set to NONE
(the default), no statistics are returned.
* @see ReturnItemCollectionMetrics
*/
public final ReturnItemCollectionMetrics returnItemCollectionMetrics() {
return ReturnItemCollectionMetrics.fromValue(returnItemCollectionMetrics);
}
/**
*
* Determines whether item collection metrics are returned. If set to SIZE
, the response includes
* statistics about item collections, if any, that were modified during the operation are returned in the response.
* If set to NONE
(the default), no statistics are returned.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnItemCollectionMetrics} will return {@link ReturnItemCollectionMetrics#UNKNOWN_TO_SDK_VERSION}. The
* raw value returned by the service is available from {@link #returnItemCollectionMetricsAsString}.
*
*
* @return Determines whether item collection metrics are returned. If set to SIZE
, the response
* includes statistics about item collections, if any, that were modified during the operation are returned
* in the response. If set to NONE
(the default), no statistics are returned.
* @see ReturnItemCollectionMetrics
*/
public final String returnItemCollectionMetricsAsString() {
return returnItemCollectionMetrics;
}
/**
*
* An expression that defines one or more attributes to be updated, the action to be performed on them, and new
* values for them.
*
*
* The following action values are available for UpdateExpression
.
*
*
*
*
* SET
- Adds one or more attributes and values to an item. If any of these attributes already exist,
* they are replaced by the new values. You can also use SET
to add or subtract from an attribute that
* is of type Number. For example: SET myNum = myNum + :val
*
*
* SET
supports the following functions:
*
*
*
*
* if_not_exists (path, operand)
- if the item does not contain an attribute at the specified path,
* then if_not_exists
evaluates to operand; otherwise, it evaluates to path. You can use this function
* to avoid overwriting an attribute that may already be present in the item.
*
*
*
*
* list_append (operand, operand)
- evaluates to a list with a new element added to it. You can append
* the new element to the start or the end of the list by reversing the order of the operands.
*
*
*
*
* These function names are case-sensitive.
*
*
*
*
* REMOVE
- Removes one or more attributes from an item.
*
*
*
*
* ADD
- Adds the specified value to the item, if the attribute does not already exist. If the
* attribute does exist, then the behavior of ADD
depends on the data type of the attribute:
*
*
*
*
* If the existing attribute is a number, and if Value
is also a number, then Value
is
* mathematically added to the existing attribute. If Value
is a negative number, then it is subtracted
* from the existing attribute.
*
*
*
* If you use ADD
to increment or decrement a number value for an item that doesn't exist before the
* update, DynamoDB uses 0
as the initial value.
*
*
* Similarly, if you use ADD
for an existing item to increment or decrement an attribute value that
* doesn't exist before the update, DynamoDB uses 0
as the initial value. For example, suppose that the
* item you want to update doesn't have an attribute named itemcount
, but you decide to
* ADD
the number 3
to this attribute anyway. DynamoDB will create the
* itemcount
attribute, set its initial value to 0
, and finally add 3
to it.
* The result will be a new itemcount
attribute in the item, with a value of 3
.
*
*
*
*
* If the existing data type is a set and if Value
is also a set, then Value
is added to
* the existing set. For example, if the attribute value is the set [1,2]
, and the ADD
* action specified [3]
, then the final attribute value is [1,2,3]
. An error occurs if an
* ADD
action is specified for a set attribute and the attribute type specified does not match the
* existing set type.
*
*
* Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
* Value
must also be a set of strings.
*
*
*
*
*
* The ADD
action only supports Number and set data types. In addition, ADD
can only be
* used on top-level attributes, not nested attributes.
*
*
*
*
* DELETE
- Deletes an element from a set.
*
*
* If a set of values is specified, then those values are subtracted from the old set. For example, if the attribute
* value was the set [a,b,c]
and the DELETE
action specifies [a,c]
, then the
* final attribute value is [b]
. Specifying an empty set is an error.
*
*
*
* The DELETE
action only supports set data types. In addition, DELETE
can only be used on
* top-level attributes, not nested attributes.
*
*
*
*
* You can have many actions in a single expression, such as the following:
* SET a=:value1, b=:value2 DELETE :value3, :value4, :value5
*
*
* For more information on update expressions, see Modifying
* Items and Attributes in the Amazon DynamoDB Developer Guide .
*
*
* @return An expression that defines one or more attributes to be updated, the action to be performed on them, and
* new values for them.
*
* The following action values are available for UpdateExpression
.
*
*
*
*
* SET
- Adds one or more attributes and values to an item. If any of these attributes already
* exist, they are replaced by the new values. You can also use SET
to add or subtract from an
* attribute that is of type Number. For example: SET myNum = myNum + :val
*
*
* SET
supports the following functions:
*
*
*
*
* if_not_exists (path, operand)
- if the item does not contain an attribute at the specified
* path, then if_not_exists
evaluates to operand; otherwise, it evaluates to path. You can use
* this function to avoid overwriting an attribute that may already be present in the item.
*
*
*
*
* list_append (operand, operand)
- evaluates to a list with a new element added to it. You can
* append the new element to the start or the end of the list by reversing the order of the operands.
*
*
*
*
* These function names are case-sensitive.
*
*
*
*
* REMOVE
- Removes one or more attributes from an item.
*
*
*
*
* ADD
- Adds the specified value to the item, if the attribute does not already exist. If the
* attribute does exist, then the behavior of ADD
depends on the data type of the attribute:
*
*
*
*
* If the existing attribute is a number, and if Value
is also a number, then
* Value
is mathematically added to the existing attribute. If Value
is a negative
* number, then it is subtracted from the existing attribute.
*
*
*
* If you use ADD
to increment or decrement a number value for an item that doesn't exist
* before the update, DynamoDB uses 0
as the initial value.
*
*
* Similarly, if you use ADD
for an existing item to increment or decrement an attribute value
* that doesn't exist before the update, DynamoDB uses 0
as the initial value. For example,
* suppose that the item you want to update doesn't have an attribute named itemcount
, but you
* decide to ADD
the number 3
to this attribute anyway. DynamoDB will create the
* itemcount
attribute, set its initial value to 0
, and finally add 3
* to it. The result will be a new itemcount
attribute in the item, with a value of
* 3
.
*
*
*
*
* If the existing data type is a set and if Value
is also a set, then Value
is
* added to the existing set. For example, if the attribute value is the set [1,2]
, and the
* ADD
action specified [3]
, then the final attribute value is
* [1,2,3]
. An error occurs if an ADD
action is specified for a set attribute and
* the attribute type specified does not match the existing set type.
*
*
* Both sets must have the same primitive data type. For example, if the existing data type is a set of
* strings, the Value
must also be a set of strings.
*
*
*
*
*
* The ADD
action only supports Number and set data types. In addition, ADD
can
* only be used on top-level attributes, not nested attributes.
*
*
*
*
* DELETE
- Deletes an element from a set.
*
*
* If a set of values is specified, then those values are subtracted from the old set. For example, if the
* attribute value was the set [a,b,c]
and the DELETE
action specifies
* [a,c]
, then the final attribute value is [b]
. Specifying an empty set is an
* error.
*
*
*
* The DELETE
action only supports set data types. In addition, DELETE
can only be
* used on top-level attributes, not nested attributes.
*
*
*
*
* You can have many actions in a single expression, such as the following:
* SET a=:value1, b=:value2 DELETE :value3, :value4, :value5
*
*
* For more information on update expressions, see Modifying Items and Attributes in the Amazon DynamoDB Developer Guide .
*/
public final String updateExpression() {
return updateExpression;
}
/**
*
* A condition that must be satisfied in order for a conditional update to succeed.
*
*
* An expression can contain any of the following:
*
*
*
*
* Functions: attribute_exists | attribute_not_exists | attribute_type | contains | begins_with | size
*
*
* These function names are case-sensitive.
*
*
*
*
* Comparison operators: = | <> | < | > | <= | >= | BETWEEN | IN
*
*
*
*
* Logical operators: AND | OR | NOT
*
*
*
*
* For more information about condition expressions, see Specifying Conditions in the Amazon DynamoDB Developer Guide .
*
*
* @return A condition that must be satisfied in order for a conditional update to succeed.
*
* An expression can contain any of the following:
*
*
*
*
* Functions:
* attribute_exists | attribute_not_exists | attribute_type | contains | begins_with | size
*
*
* These function names are case-sensitive.
*
*
*
*
* Comparison operators: = | <> | < | > | <= | >= | BETWEEN | IN
*
*
*
*
* Logical operators: AND | OR | NOT
*
*
*
*
* For more information about condition expressions, see Specifying Conditions in the Amazon DynamoDB Developer Guide .
*/
public final String conditionExpression() {
return conditionExpression;
}
/**
* For responses, this returns true if the service returned a value for the ExpressionAttributeNames property. This
* DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the
* property). This is useful because the SDK will never return a null collection or map, but you may need to
* differentiate between the service returning nothing (or null) and the service returning an empty collection or
* map. For requests, this returns true if a value for the property was specified in the request builder, and false
* if a value was not specified.
*/
public final boolean hasExpressionAttributeNames() {
return expressionAttributeNames != null && !(expressionAttributeNames instanceof SdkAutoConstructMap);
}
/**
*
* One or more substitution tokens for attribute names in an expression. The following are some use cases for using
* ExpressionAttributeNames
:
*
*
*
*
* To access an attribute whose name conflicts with a DynamoDB reserved word.
*
*
*
*
* To create a placeholder for repeating occurrences of an attribute name in an expression.
*
*
*
*
* To prevent special characters in an attribute name from being misinterpreted in an expression.
*
*
*
*
* Use the # character in an expression to dereference an attribute name. For example, consider the following
* attribute name:
*
*
*
* The name of this attribute conflicts with a reserved word, so it cannot be used directly in an expression. (For
* the complete list of reserved words, see Reserved Words in
* the Amazon DynamoDB Developer Guide .) To work around this, you could specify the following for
* ExpressionAttributeNames
:
*
*
*
*
* {"#P":"Percentile"}
*
*
*
*
* You could then use this substitution in an expression, as in this example:
*
*
*
*
* Tokens that begin with the : character are expression attribute values , which are placeholders for
* the actual value at runtime.
*
*
*
* For more information about expression attribute names, see Specifying Item Attributes in the Amazon DynamoDB Developer Guide .
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasExpressionAttributeNames} method.
*
*
* @return One or more substitution tokens for attribute names in an expression. The following are some use cases
* for using ExpressionAttributeNames
:
*
*
*
* To access an attribute whose name conflicts with a DynamoDB reserved word.
*
*
*
*
* To create a placeholder for repeating occurrences of an attribute name in an expression.
*
*
*
*
* To prevent special characters in an attribute name from being misinterpreted in an expression.
*
*
*
*
* Use the # character in an expression to dereference an attribute name. For example, consider the
* following attribute name:
*
*
*
* The name of this attribute conflicts with a reserved word, so it cannot be used directly in an
* expression. (For the complete list of reserved words, see Reserved
* Words in the Amazon DynamoDB Developer Guide .) To work around this, you could specify the
* following for ExpressionAttributeNames
:
*
*
*
*
* {"#P":"Percentile"}
*
*
*
*
* You could then use this substitution in an expression, as in this example:
*
*
*
*
* Tokens that begin with the : character are expression attribute values , which are
* placeholders for the actual value at runtime.
*
*
*
* For more information about expression attribute names, see Specifying Item Attributes in the Amazon DynamoDB Developer Guide .
*/
public final Map expressionAttributeNames() {
return expressionAttributeNames;
}
/**
* For responses, this returns true if the service returned a value for the ExpressionAttributeValues property. This
* DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the
* property). This is useful because the SDK will never return a null collection or map, but you may need to
* differentiate between the service returning nothing (or null) and the service returning an empty collection or
* map. For requests, this returns true if a value for the property was specified in the request builder, and false
* if a value was not specified.
*/
public final boolean hasExpressionAttributeValues() {
return expressionAttributeValues != null && !(expressionAttributeValues instanceof SdkAutoConstructMap);
}
/**
*
* One or more values that can be substituted in an expression.
*
*
* Use the : (colon) character in an expression to dereference an attribute value. For example, suppose that
* you wanted to check whether the value of the ProductStatus
attribute was one of the following:
*
*
* Available | Backordered | Discontinued
*
*
* You would first need to specify ExpressionAttributeValues
as follows:
*
*
* { ":avail":{"S":"Available"}, ":back":{"S":"Backordered"}, ":disc":{"S":"Discontinued"} }
*
*
* You could then use these values in an expression, such as this:
*
*
* ProductStatus IN (:avail, :back, :disc)
*
*
* For more information on expression attribute values, see Condition Expressions in the Amazon DynamoDB Developer Guide .
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasExpressionAttributeValues} method.
*
*
* @return One or more values that can be substituted in an expression.
*
* Use the : (colon) character in an expression to dereference an attribute value. For example,
* suppose that you wanted to check whether the value of the ProductStatus
attribute was one of
* the following:
*
*
* Available | Backordered | Discontinued
*
*
* You would first need to specify ExpressionAttributeValues
as follows:
*
*
* { ":avail":{"S":"Available"}, ":back":{"S":"Backordered"}, ":disc":{"S":"Discontinued"} }
*
*
* You could then use these values in an expression, such as this:
*
*
* ProductStatus IN (:avail, :back, :disc)
*
*
* For more information on expression attribute values, see Condition Expressions in the Amazon DynamoDB Developer Guide .
*/
public final Map expressionAttributeValues() {
return expressionAttributeValues;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(tableName());
hashCode = 31 * hashCode + Objects.hashCode(hasKey() ? key() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasAttributeUpdates() ? attributeUpdates() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasExpected() ? expected() : null);
hashCode = 31 * hashCode + Objects.hashCode(conditionalOperatorAsString());
hashCode = 31 * hashCode + Objects.hashCode(returnValuesAsString());
hashCode = 31 * hashCode + Objects.hashCode(returnConsumedCapacityAsString());
hashCode = 31 * hashCode + Objects.hashCode(returnItemCollectionMetricsAsString());
hashCode = 31 * hashCode + Objects.hashCode(updateExpression());
hashCode = 31 * hashCode + Objects.hashCode(conditionExpression());
hashCode = 31 * hashCode + Objects.hashCode(hasExpressionAttributeNames() ? expressionAttributeNames() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasExpressionAttributeValues() ? expressionAttributeValues() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof UpdateItemRequest)) {
return false;
}
UpdateItemRequest other = (UpdateItemRequest) obj;
return Objects.equals(tableName(), other.tableName()) && hasKey() == other.hasKey() && Objects.equals(key(), other.key())
&& hasAttributeUpdates() == other.hasAttributeUpdates()
&& Objects.equals(attributeUpdates(), other.attributeUpdates()) && hasExpected() == other.hasExpected()
&& Objects.equals(expected(), other.expected())
&& Objects.equals(conditionalOperatorAsString(), other.conditionalOperatorAsString())
&& Objects.equals(returnValuesAsString(), other.returnValuesAsString())
&& Objects.equals(returnConsumedCapacityAsString(), other.returnConsumedCapacityAsString())
&& Objects.equals(returnItemCollectionMetricsAsString(), other.returnItemCollectionMetricsAsString())
&& Objects.equals(updateExpression(), other.updateExpression())
&& Objects.equals(conditionExpression(), other.conditionExpression())
&& hasExpressionAttributeNames() == other.hasExpressionAttributeNames()
&& Objects.equals(expressionAttributeNames(), other.expressionAttributeNames())
&& hasExpressionAttributeValues() == other.hasExpressionAttributeValues()
&& Objects.equals(expressionAttributeValues(), other.expressionAttributeValues());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("UpdateItemRequest").add("TableName", tableName()).add("Key", hasKey() ? key() : null)
.add("AttributeUpdates", hasAttributeUpdates() ? attributeUpdates() : null)
.add("Expected", hasExpected() ? expected() : null).add("ConditionalOperator", conditionalOperatorAsString())
.add("ReturnValues", returnValuesAsString()).add("ReturnConsumedCapacity", returnConsumedCapacityAsString())
.add("ReturnItemCollectionMetrics", returnItemCollectionMetricsAsString())
.add("UpdateExpression", updateExpression()).add("ConditionExpression", conditionExpression())
.add("ExpressionAttributeNames", hasExpressionAttributeNames() ? expressionAttributeNames() : null)
.add("ExpressionAttributeValues", hasExpressionAttributeValues() ? expressionAttributeValues() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TableName":
return Optional.ofNullable(clazz.cast(tableName()));
case "Key":
return Optional.ofNullable(clazz.cast(key()));
case "AttributeUpdates":
return Optional.ofNullable(clazz.cast(attributeUpdates()));
case "Expected":
return Optional.ofNullable(clazz.cast(expected()));
case "ConditionalOperator":
return Optional.ofNullable(clazz.cast(conditionalOperatorAsString()));
case "ReturnValues":
return Optional.ofNullable(clazz.cast(returnValuesAsString()));
case "ReturnConsumedCapacity":
return Optional.ofNullable(clazz.cast(returnConsumedCapacityAsString()));
case "ReturnItemCollectionMetrics":
return Optional.ofNullable(clazz.cast(returnItemCollectionMetricsAsString()));
case "UpdateExpression":
return Optional.ofNullable(clazz.cast(updateExpression()));
case "ConditionExpression":
return Optional.ofNullable(clazz.cast(conditionExpression()));
case "ExpressionAttributeNames":
return Optional.ofNullable(clazz.cast(expressionAttributeNames()));
case "ExpressionAttributeValues":
return Optional.ofNullable(clazz.cast(expressionAttributeValues()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((UpdateItemRequest) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends DynamoDbRequest.Builder, SdkPojo, CopyableBuilder {
/**
*
* The name of the table containing the item to update.
*
*
* @param tableName
* The name of the table containing the item to update.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder tableName(String tableName);
/**
*
* The primary key of the item to be updated. Each element consists of an attribute name and a value for that
* attribute.
*
*
* For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only
* need to provide a value for the partition key. For a composite primary key, you must provide values for both
* the partition key and the sort key.
*
*
* @param key
* The primary key of the item to be updated. Each element consists of an attribute name and a value for
* that attribute.
*
* For the primary key, you must provide all of the attributes. For example, with a simple primary key,
* you only need to provide a value for the partition key. For a composite primary key, you must provide
* values for both the partition key and the sort key.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder key(Map key);
/**
*
* This is a legacy parameter. Use UpdateExpression
instead. For more information, see AttributeUpdates in the Amazon DynamoDB Developer Guide .
*
*
* @param attributeUpdates
* This is a legacy parameter. Use UpdateExpression
instead. For more information, see AttributeUpdates in the Amazon DynamoDB Developer Guide .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder attributeUpdates(Map attributeUpdates);
/**
*
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see Expected in the Amazon DynamoDB Developer Guide .
*
*
* @param expected
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see Expected in the Amazon DynamoDB Developer Guide .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder expected(Map expected);
/**
*
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
*
*
* @param conditionalOperator
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
* @see ConditionalOperator
* @return Returns a reference to this object so that method calls can be chained together.
* @see ConditionalOperator
*/
Builder conditionalOperator(String conditionalOperator);
/**
*
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
*
*
* @param conditionalOperator
* This is a legacy parameter. Use ConditionExpression
instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
* @see ConditionalOperator
* @return Returns a reference to this object so that method calls can be chained together.
* @see ConditionalOperator
*/
Builder conditionalOperator(ConditionalOperator conditionalOperator);
/**
*
* Use ReturnValues
if you want to get the item attributes as they appear before or after they are
* updated. For UpdateItem
, the valid values are:
*
*
*
*
* NONE
- If ReturnValues
is not specified, or if its value is NONE
, then
* nothing is returned. (This setting is the default for ReturnValues
.)
*
*
*
*
* ALL_OLD
- Returns all of the attributes of the item, as they appeared before the UpdateItem
* operation.
*
*
*
*
* UPDATED_OLD
- Returns only the updated attributes, as they appeared before the UpdateItem
* operation.
*
*
*
*
* ALL_NEW
- Returns all of the attributes of the item, as they appear after the UpdateItem
* operation.
*
*
*
*
* UPDATED_NEW
- Returns only the updated attributes, as they appear after the UpdateItem
* operation.
*
*
*
*
* There is no additional cost associated with requesting a return value aside from the small network and
* processing overhead of receiving a larger response. No read capacity units are consumed.
*
*
* The values returned are strongly consistent.
*
*
* @param returnValues
* Use ReturnValues
if you want to get the item attributes as they appear before or after
* they are updated. For UpdateItem
, the valid values are:
*
*
*
* NONE
- If ReturnValues
is not specified, or if its value is
* NONE
, then nothing is returned. (This setting is the default for
* ReturnValues
.)
*
*
*
*
* ALL_OLD
- Returns all of the attributes of the item, as they appeared before the
* UpdateItem operation.
*
*
*
*
* UPDATED_OLD
- Returns only the updated attributes, as they appeared before the UpdateItem
* operation.
*
*
*
*
* ALL_NEW
- Returns all of the attributes of the item, as they appear after the UpdateItem
* operation.
*
*
*
*
* UPDATED_NEW
- Returns only the updated attributes, as they appear after the UpdateItem
* operation.
*
*
*
*
* There is no additional cost associated with requesting a return value aside from the small network and
* processing overhead of receiving a larger response. No read capacity units are consumed.
*
*
* The values returned are strongly consistent.
* @see ReturnValue
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnValue
*/
Builder returnValues(String returnValues);
/**
*
* Use ReturnValues
if you want to get the item attributes as they appear before or after they are
* updated. For UpdateItem
, the valid values are:
*
*
*
*
* NONE
- If ReturnValues
is not specified, or if its value is NONE
, then
* nothing is returned. (This setting is the default for ReturnValues
.)
*
*
*
*
* ALL_OLD
- Returns all of the attributes of the item, as they appeared before the UpdateItem
* operation.
*
*
*
*
* UPDATED_OLD
- Returns only the updated attributes, as they appeared before the UpdateItem
* operation.
*
*
*
*
* ALL_NEW
- Returns all of the attributes of the item, as they appear after the UpdateItem
* operation.
*
*
*
*
* UPDATED_NEW
- Returns only the updated attributes, as they appear after the UpdateItem
* operation.
*
*
*
*
* There is no additional cost associated with requesting a return value aside from the small network and
* processing overhead of receiving a larger response. No read capacity units are consumed.
*
*
* The values returned are strongly consistent.
*
*
* @param returnValues
* Use ReturnValues
if you want to get the item attributes as they appear before or after
* they are updated. For UpdateItem
, the valid values are:
*
*
*
* NONE
- If ReturnValues
is not specified, or if its value is
* NONE
, then nothing is returned. (This setting is the default for
* ReturnValues
.)
*
*
*
*
* ALL_OLD
- Returns all of the attributes of the item, as they appeared before the
* UpdateItem operation.
*
*
*
*
* UPDATED_OLD
- Returns only the updated attributes, as they appeared before the UpdateItem
* operation.
*
*
*
*
* ALL_NEW
- Returns all of the attributes of the item, as they appear after the UpdateItem
* operation.
*
*
*
*
* UPDATED_NEW
- Returns only the updated attributes, as they appear after the UpdateItem
* operation.
*
*
*
*
* There is no additional cost associated with requesting a return value aside from the small network and
* processing overhead of receiving a larger response. No read capacity units are consumed.
*
*
* The values returned are strongly consistent.
* @see ReturnValue
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnValue
*/
Builder returnValues(ReturnValue returnValues);
/**
* Sets the value of the ReturnConsumedCapacity property for this object.
*
* @param returnConsumedCapacity
* The new value for the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnConsumedCapacity
*/
Builder returnConsumedCapacity(String returnConsumedCapacity);
/**
* Sets the value of the ReturnConsumedCapacity property for this object.
*
* @param returnConsumedCapacity
* The new value for the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnConsumedCapacity
*/
Builder returnConsumedCapacity(ReturnConsumedCapacity returnConsumedCapacity);
/**
*
* Determines whether item collection metrics are returned. If set to SIZE
, the response includes
* statistics about item collections, if any, that were modified during the operation are returned in the
* response. If set to NONE
(the default), no statistics are returned.
*
*
* @param returnItemCollectionMetrics
* Determines whether item collection metrics are returned. If set to SIZE
, the response
* includes statistics about item collections, if any, that were modified during the operation are
* returned in the response. If set to NONE
(the default), no statistics are returned.
* @see ReturnItemCollectionMetrics
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnItemCollectionMetrics
*/
Builder returnItemCollectionMetrics(String returnItemCollectionMetrics);
/**
*
* Determines whether item collection metrics are returned. If set to SIZE
, the response includes
* statistics about item collections, if any, that were modified during the operation are returned in the
* response. If set to NONE
(the default), no statistics are returned.
*
*
* @param returnItemCollectionMetrics
* Determines whether item collection metrics are returned. If set to SIZE
, the response
* includes statistics about item collections, if any, that were modified during the operation are
* returned in the response. If set to NONE
(the default), no statistics are returned.
* @see ReturnItemCollectionMetrics
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnItemCollectionMetrics
*/
Builder returnItemCollectionMetrics(ReturnItemCollectionMetrics returnItemCollectionMetrics);
/**
*
* An expression that defines one or more attributes to be updated, the action to be performed on them, and new
* values for them.
*
*
* The following action values are available for UpdateExpression
.
*
*
*
*
* SET
- Adds one or more attributes and values to an item. If any of these attributes already
* exist, they are replaced by the new values. You can also use SET
to add or subtract from an
* attribute that is of type Number. For example: SET myNum = myNum + :val
*
*
* SET
supports the following functions:
*
*
*
*
* if_not_exists (path, operand)
- if the item does not contain an attribute at the specified path,
* then if_not_exists
evaluates to operand; otherwise, it evaluates to path. You can use this
* function to avoid overwriting an attribute that may already be present in the item.
*
*
*
*
* list_append (operand, operand)
- evaluates to a list with a new element added to it. You can
* append the new element to the start or the end of the list by reversing the order of the operands.
*
*
*
*
* These function names are case-sensitive.
*
*
*
*
* REMOVE
- Removes one or more attributes from an item.
*
*
*
*
* ADD
- Adds the specified value to the item, if the attribute does not already exist. If the
* attribute does exist, then the behavior of ADD
depends on the data type of the attribute:
*
*
*
*
* If the existing attribute is a number, and if Value
is also a number, then Value
is
* mathematically added to the existing attribute. If Value
is a negative number, then it is
* subtracted from the existing attribute.
*
*
*
* If you use ADD
to increment or decrement a number value for an item that doesn't exist before
* the update, DynamoDB uses 0
as the initial value.
*
*
* Similarly, if you use ADD
for an existing item to increment or decrement an attribute value that
* doesn't exist before the update, DynamoDB uses 0
as the initial value. For example, suppose that
* the item you want to update doesn't have an attribute named itemcount
, but you decide to
* ADD
the number 3
to this attribute anyway. DynamoDB will create the
* itemcount
attribute, set its initial value to 0
, and finally add 3
to
* it. The result will be a new itemcount
attribute in the item, with a value of 3
.
*
*
*
*
* If the existing data type is a set and if Value
is also a set, then Value
is added
* to the existing set. For example, if the attribute value is the set [1,2]
, and the
* ADD
action specified [3]
, then the final attribute value is [1,2,3]
.
* An error occurs if an ADD
action is specified for a set attribute and the attribute type
* specified does not match the existing set type.
*
*
* Both sets must have the same primitive data type. For example, if the existing data type is a set of strings,
* the Value
must also be a set of strings.
*
*
*
*
*
* The ADD
action only supports Number and set data types. In addition, ADD
can only
* be used on top-level attributes, not nested attributes.
*
*
*
*
* DELETE
- Deletes an element from a set.
*
*
* If a set of values is specified, then those values are subtracted from the old set. For example, if the
* attribute value was the set [a,b,c]
and the DELETE
action specifies
* [a,c]
, then the final attribute value is [b]
. Specifying an empty set is an error.
*
*
*
* The DELETE
action only supports set data types. In addition, DELETE
can only be
* used on top-level attributes, not nested attributes.
*
*
*
*
* You can have many actions in a single expression, such as the following:
* SET a=:value1, b=:value2 DELETE :value3, :value4, :value5
*
*
* For more information on update expressions, see Modifying
* Items and Attributes in the Amazon DynamoDB Developer Guide .
*
*
* @param updateExpression
* An expression that defines one or more attributes to be updated, the action to be performed on them,
* and new values for them.
*
* The following action values are available for UpdateExpression
.
*
*
*
*
* SET
- Adds one or more attributes and values to an item. If any of these attributes
* already exist, they are replaced by the new values. You can also use SET
to add or
* subtract from an attribute that is of type Number. For example: SET myNum = myNum + :val
*
*
* SET
supports the following functions:
*
*
*
*
* if_not_exists (path, operand)
- if the item does not contain an attribute at the
* specified path, then if_not_exists
evaluates to operand; otherwise, it evaluates to path.
* You can use this function to avoid overwriting an attribute that may already be present in the item.
*
*
*
*
* list_append (operand, operand)
- evaluates to a list with a new element added to it. You
* can append the new element to the start or the end of the list by reversing the order of the operands.
*
*
*
*
* These function names are case-sensitive.
*
*
*
*
* REMOVE
- Removes one or more attributes from an item.
*
*
*
*
* ADD
- Adds the specified value to the item, if the attribute does not already exist. If
* the attribute does exist, then the behavior of ADD
depends on the data type of the
* attribute:
*
*
*
*
* If the existing attribute is a number, and if Value
is also a number, then
* Value
is mathematically added to the existing attribute. If Value
is a
* negative number, then it is subtracted from the existing attribute.
*
*
*
* If you use ADD
to increment or decrement a number value for an item that doesn't exist
* before the update, DynamoDB uses 0
as the initial value.
*
*
* Similarly, if you use ADD
for an existing item to increment or decrement an attribute
* value that doesn't exist before the update, DynamoDB uses 0
as the initial value. For
* example, suppose that the item you want to update doesn't have an attribute named
* itemcount
, but you decide to ADD
the number 3
to this attribute
* anyway. DynamoDB will create the itemcount
attribute, set its initial value to
* 0
, and finally add 3
to it. The result will be a new itemcount
* attribute in the item, with a value of 3
.
*
*
*
*
* If the existing data type is a set and if Value
is also a set, then Value
is
* added to the existing set. For example, if the attribute value is the set [1,2]
, and the
* ADD
action specified [3]
, then the final attribute value is
* [1,2,3]
. An error occurs if an ADD
action is specified for a set attribute
* and the attribute type specified does not match the existing set type.
*
*
* Both sets must have the same primitive data type. For example, if the existing data type is a set of
* strings, the Value
must also be a set of strings.
*
*
*
*
*
* The ADD
action only supports Number and set data types. In addition, ADD
can
* only be used on top-level attributes, not nested attributes.
*
*
*
*
* DELETE
- Deletes an element from a set.
*
*
* If a set of values is specified, then those values are subtracted from the old set. For example, if
* the attribute value was the set [a,b,c]
and the DELETE
action specifies
* [a,c]
, then the final attribute value is [b]
. Specifying an empty set is an
* error.
*
*
*
* The DELETE
action only supports set data types. In addition, DELETE
can only
* be used on top-level attributes, not nested attributes.
*
*
*
*
* You can have many actions in a single expression, such as the following:
* SET a=:value1, b=:value2 DELETE :value3, :value4, :value5
*
*
* For more information on update expressions, see Modifying Items and Attributes in the Amazon DynamoDB Developer Guide .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder updateExpression(String updateExpression);
/**
*
* A condition that must be satisfied in order for a conditional update to succeed.
*
*
* An expression can contain any of the following:
*
*
*
*
* Functions:
* attribute_exists | attribute_not_exists | attribute_type | contains | begins_with | size
*
*
* These function names are case-sensitive.
*
*
*
*
* Comparison operators: = | <> | < | > | <= | >= | BETWEEN | IN
*
*
*
*
* Logical operators: AND | OR | NOT
*
*
*
*
* For more information about condition expressions, see Specifying Conditions in the Amazon DynamoDB Developer Guide .
*
*
* @param conditionExpression
* A condition that must be satisfied in order for a conditional update to succeed.
*
* An expression can contain any of the following:
*
*
*
*
* Functions:
* attribute_exists | attribute_not_exists | attribute_type | contains | begins_with | size
*
*
* These function names are case-sensitive.
*
*
*
*
* Comparison operators: = | <> | < | > | <= | >= | BETWEEN | IN
*
*
*
*
* Logical operators: AND | OR | NOT
*
*
*
*
* For more information about condition expressions, see Specifying Conditions in the Amazon DynamoDB Developer Guide .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder conditionExpression(String conditionExpression);
/**
*
* One or more substitution tokens for attribute names in an expression. The following are some use cases for
* using ExpressionAttributeNames
:
*
*
*
*
* To access an attribute whose name conflicts with a DynamoDB reserved word.
*
*
*
*
* To create a placeholder for repeating occurrences of an attribute name in an expression.
*
*
*
*
* To prevent special characters in an attribute name from being misinterpreted in an expression.
*
*
*
*
* Use the # character in an expression to dereference an attribute name. For example, consider the
* following attribute name:
*
*
*
* The name of this attribute conflicts with a reserved word, so it cannot be used directly in an expression.
* (For the complete list of reserved words, see Reserved Words
* in the Amazon DynamoDB Developer Guide .) To work around this, you could specify the following for
* ExpressionAttributeNames
:
*
*
*
*
* {"#P":"Percentile"}
*
*
*
*
* You could then use this substitution in an expression, as in this example:
*
*
*
*
* Tokens that begin with the : character are expression attribute values , which are placeholders
* for the actual value at runtime.
*
*
*
* For more information about expression attribute names, see Specifying Item Attributes in the Amazon DynamoDB Developer Guide .
*
*
* @param expressionAttributeNames
* One or more substitution tokens for attribute names in an expression. The following are some use cases
* for using ExpressionAttributeNames
:
*
*
*
* To access an attribute whose name conflicts with a DynamoDB reserved word.
*
*
*
*
* To create a placeholder for repeating occurrences of an attribute name in an expression.
*
*
*
*
* To prevent special characters in an attribute name from being misinterpreted in an expression.
*
*
*
*
* Use the # character in an expression to dereference an attribute name. For example, consider
* the following attribute name:
*
*
*
* The name of this attribute conflicts with a reserved word, so it cannot be used directly in an
* expression. (For the complete list of reserved words, see Reserved
* Words in the Amazon DynamoDB Developer Guide .) To work around this, you could specify the
* following for ExpressionAttributeNames
:
*
*
*
*
* {"#P":"Percentile"}
*
*
*
*
* You could then use this substitution in an expression, as in this example:
*
*
*
*
* Tokens that begin with the : character are expression attribute values , which are
* placeholders for the actual value at runtime.
*
*
*
* For more information about expression attribute names, see Specifying Item Attributes in the Amazon DynamoDB Developer Guide .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder expressionAttributeNames(Map expressionAttributeNames);
/**
*
* One or more values that can be substituted in an expression.
*
*
* Use the : (colon) character in an expression to dereference an attribute value. For example, suppose
* that you wanted to check whether the value of the ProductStatus
attribute was one of the
* following:
*
*
* Available | Backordered | Discontinued
*
*
* You would first need to specify ExpressionAttributeValues
as follows:
*
*
* { ":avail":{"S":"Available"}, ":back":{"S":"Backordered"}, ":disc":{"S":"Discontinued"} }
*
*
* You could then use these values in an expression, such as this:
*
*
* ProductStatus IN (:avail, :back, :disc)
*
*
* For more information on expression attribute values, see Condition Expressions in the Amazon DynamoDB Developer Guide .
*
*
* @param expressionAttributeValues
* One or more values that can be substituted in an expression.
*
* Use the : (colon) character in an expression to dereference an attribute value. For example,
* suppose that you wanted to check whether the value of the ProductStatus
attribute was one
* of the following:
*
*
* Available | Backordered | Discontinued
*
*
* You would first need to specify ExpressionAttributeValues
as follows:
*
*
* { ":avail":{"S":"Available"}, ":back":{"S":"Backordered"}, ":disc":{"S":"Discontinued"} }
*
*
* You could then use these values in an expression, such as this:
*
*
* ProductStatus IN (:avail, :back, :disc)
*
*
* For more information on expression attribute values, see Condition Expressions in the Amazon DynamoDB Developer Guide .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder expressionAttributeValues(Map expressionAttributeValues);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends DynamoDbRequest.BuilderImpl implements Builder {
private String tableName;
private Map key = DefaultSdkAutoConstructMap.getInstance();
private Map attributeUpdates = DefaultSdkAutoConstructMap.getInstance();
private Map expected = DefaultSdkAutoConstructMap.getInstance();
private String conditionalOperator;
private String returnValues;
private String returnConsumedCapacity;
private String returnItemCollectionMetrics;
private String updateExpression;
private String conditionExpression;
private Map expressionAttributeNames = DefaultSdkAutoConstructMap.getInstance();
private Map expressionAttributeValues = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(UpdateItemRequest model) {
super(model);
tableName(model.tableName);
key(model.key);
attributeUpdates(model.attributeUpdates);
expected(model.expected);
conditionalOperator(model.conditionalOperator);
returnValues(model.returnValues);
returnConsumedCapacity(model.returnConsumedCapacity);
returnItemCollectionMetrics(model.returnItemCollectionMetrics);
updateExpression(model.updateExpression);
conditionExpression(model.conditionExpression);
expressionAttributeNames(model.expressionAttributeNames);
expressionAttributeValues(model.expressionAttributeValues);
}
public final String getTableName() {
return tableName;
}
public final void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
@Transient
public final Builder tableName(String tableName) {
this.tableName = tableName;
return this;
}
public final Map getKey() {
Map result = KeyCopier.copyToBuilder(this.key);
if (result instanceof SdkAutoConstructMap) {
return null;
}
return result;
}
public final void setKey(Map key) {
this.key = KeyCopier.copyFromBuilder(key);
}
@Override
@Transient
public final Builder key(Map key) {
this.key = KeyCopier.copy(key);
return this;
}
public final Map getAttributeUpdates() {
Map result = AttributeUpdatesCopier.copyToBuilder(this.attributeUpdates);
if (result instanceof SdkAutoConstructMap) {
return null;
}
return result;
}
public final void setAttributeUpdates(Map attributeUpdates) {
this.attributeUpdates = AttributeUpdatesCopier.copyFromBuilder(attributeUpdates);
}
@Override
@Transient
public final Builder attributeUpdates(Map attributeUpdates) {
this.attributeUpdates = AttributeUpdatesCopier.copy(attributeUpdates);
return this;
}
public final Map getExpected() {
Map result = ExpectedAttributeMapCopier.copyToBuilder(this.expected);
if (result instanceof SdkAutoConstructMap) {
return null;
}
return result;
}
public final void setExpected(Map expected) {
this.expected = ExpectedAttributeMapCopier.copyFromBuilder(expected);
}
@Override
@Transient
public final Builder expected(Map expected) {
this.expected = ExpectedAttributeMapCopier.copy(expected);
return this;
}
public final String getConditionalOperator() {
return conditionalOperator;
}
public final void setConditionalOperator(String conditionalOperator) {
this.conditionalOperator = conditionalOperator;
}
@Override
@Transient
public final Builder conditionalOperator(String conditionalOperator) {
this.conditionalOperator = conditionalOperator;
return this;
}
@Override
@Transient
public final Builder conditionalOperator(ConditionalOperator conditionalOperator) {
this.conditionalOperator(conditionalOperator == null ? null : conditionalOperator.toString());
return this;
}
public final String getReturnValues() {
return returnValues;
}
public final void setReturnValues(String returnValues) {
this.returnValues = returnValues;
}
@Override
@Transient
public final Builder returnValues(String returnValues) {
this.returnValues = returnValues;
return this;
}
@Override
@Transient
public final Builder returnValues(ReturnValue returnValues) {
this.returnValues(returnValues == null ? null : returnValues.toString());
return this;
}
public final String getReturnConsumedCapacity() {
return returnConsumedCapacity;
}
public final void setReturnConsumedCapacity(String returnConsumedCapacity) {
this.returnConsumedCapacity = returnConsumedCapacity;
}
@Override
@Transient
public final Builder returnConsumedCapacity(String returnConsumedCapacity) {
this.returnConsumedCapacity = returnConsumedCapacity;
return this;
}
@Override
@Transient
public final Builder returnConsumedCapacity(ReturnConsumedCapacity returnConsumedCapacity) {
this.returnConsumedCapacity(returnConsumedCapacity == null ? null : returnConsumedCapacity.toString());
return this;
}
public final String getReturnItemCollectionMetrics() {
return returnItemCollectionMetrics;
}
public final void setReturnItemCollectionMetrics(String returnItemCollectionMetrics) {
this.returnItemCollectionMetrics = returnItemCollectionMetrics;
}
@Override
@Transient
public final Builder returnItemCollectionMetrics(String returnItemCollectionMetrics) {
this.returnItemCollectionMetrics = returnItemCollectionMetrics;
return this;
}
@Override
@Transient
public final Builder returnItemCollectionMetrics(ReturnItemCollectionMetrics returnItemCollectionMetrics) {
this.returnItemCollectionMetrics(returnItemCollectionMetrics == null ? null : returnItemCollectionMetrics.toString());
return this;
}
public final String getUpdateExpression() {
return updateExpression;
}
public final void setUpdateExpression(String updateExpression) {
this.updateExpression = updateExpression;
}
@Override
@Transient
public final Builder updateExpression(String updateExpression) {
this.updateExpression = updateExpression;
return this;
}
public final String getConditionExpression() {
return conditionExpression;
}
public final void setConditionExpression(String conditionExpression) {
this.conditionExpression = conditionExpression;
}
@Override
@Transient
public final Builder conditionExpression(String conditionExpression) {
this.conditionExpression = conditionExpression;
return this;
}
public final Map getExpressionAttributeNames() {
if (expressionAttributeNames instanceof SdkAutoConstructMap) {
return null;
}
return expressionAttributeNames;
}
public final void setExpressionAttributeNames(Map expressionAttributeNames) {
this.expressionAttributeNames = ExpressionAttributeNameMapCopier.copy(expressionAttributeNames);
}
@Override
@Transient
public final Builder expressionAttributeNames(Map expressionAttributeNames) {
this.expressionAttributeNames = ExpressionAttributeNameMapCopier.copy(expressionAttributeNames);
return this;
}
public final Map getExpressionAttributeValues() {
Map result = ExpressionAttributeValueMapCopier
.copyToBuilder(this.expressionAttributeValues);
if (result instanceof SdkAutoConstructMap) {
return null;
}
return result;
}
public final void setExpressionAttributeValues(Map expressionAttributeValues) {
this.expressionAttributeValues = ExpressionAttributeValueMapCopier.copyFromBuilder(expressionAttributeValues);
}
@Override
@Transient
public final Builder expressionAttributeValues(Map expressionAttributeValues) {
this.expressionAttributeValues = ExpressionAttributeValueMapCopier.copy(expressionAttributeValues);
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public UpdateItemRequest build() {
return new UpdateItemRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}