java.lang.Object
software.amazon.awssdk.enhanced.dynamodb.update.SetAction
All Implemented Interfaces:
UpdateAction, ToCopyableBuilder<SetAction.Builder,SetAction>

public final class SetAction extends Object implements UpdateAction, ToCopyableBuilder<SetAction.Builder,SetAction>
A representation of a single UpdateExpression SET action.

At a minimum, this action must contain a path string referencing the attribute that should be acted upon and a value string referencing the value to set or change.

The value string may contain just an operand, or operands combined with '+' or '-'. Furthermore, an operand can be a reference to a specific value or a function. All references to values should be substituted with tokens using the ':value_token' syntax and values associated with the token must be explicitly added to the expressionValues map. Consult the DynamoDB UpdateExpression documentation for details on this action.

Optionally, attribute names can be substituted with tokens using the '#name_token' syntax. If tokens are used in the expression then the names associated with those tokens must be explicitly added to the expressionNames map that is also stored on this object.

Example:-

 
 //Simply setting the value of 'attributeA' to 'myAttributeValue'
 SetUpdateAction setAction1 = SetUpdateAction.builder()
                                             .path("#a")
                                             .value(":b")
                                             .putExpressionName("#a", "attributeA")
                                             .putExpressionValue(":b", myAttributeValue)
                                             .build();

 //Increasing the value of 'attributeA' with 'delta' if it already exists, otherwise sets it to 'startValue'
 SetUpdateAction setAction2 = SetUpdateAction.builder()
                                             .path("#a")
                                             .value("if_not_exists(#a, :startValue) + :delta")
                                             .putExpressionName("#a", "attributeA")
                                             .putExpressionValue(":delta", myNumericAttributeValue1)
                                             .putExpressionValue(":startValue", myNumericAttributeValue2)
                                             .build();