public final class SetAction extends Object implements UpdateAction, ToCopyableBuilder<SetAction.Builder,SetAction>
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();
Modifier and Type | Class and Description |
---|---|
static class |
SetAction.Builder
A builder for
SetAction |
Modifier and Type | Method and Description |
---|---|
static SetAction.Builder |
builder()
Constructs a new builder for
SetAction . |
boolean |
equals(Object o) |
Map<String,String> |
expressionNames() |
Map<String,AttributeValue> |
expressionValues() |
int |
hashCode() |
String |
path() |
SetAction.Builder |
toBuilder() |
String |
value() |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
copy
public static SetAction.Builder builder()
SetAction
.public SetAction.Builder toBuilder()
toBuilder
in interface ToCopyableBuilder<SetAction.Builder,SetAction>
public String path()
public String value()
public Map<String,AttributeValue> expressionValues()
Copyright © 2023. All rights reserved.