Class SetAction
- 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 singleUpdateExpression
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();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SetAction.Builder
A builder forSetAction
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SetAction.Builder
builder()
Constructs a new builder forSetAction
.boolean
equals(Object o)
Map<String,String>
expressionNames()
Map<String,AttributeValue>
expressionValues()
int
hashCode()
String
path()
SetAction.Builder
toBuilder()
String
value()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.utils.builder.ToCopyableBuilder
copy
-
-
-
-
Method Detail
-
builder
public static SetAction.Builder builder()
Constructs a new builder forSetAction
.- Returns:
- a new builder.
-
toBuilder
public SetAction.Builder toBuilder()
- Specified by:
toBuilder
in interfaceToCopyableBuilder<SetAction.Builder,SetAction>
-
path
public String path()
-
value
public String value()
-
expressionValues
public Map<String,AttributeValue> expressionValues()
-
-