Class Expression
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.Expression
-
@ThreadSafe public final class Expression extends Object
High-level representation of a DynamoDB 'expression' that can be used in various situations where the API requires or accepts an expression. In addition various convenience methods are provided to help manipulate expressions.At a minimum, an expression must contain a string that is the expression itself.
Optionally, attribute names can be substituted with tokens using the '#name_token' syntax; also attribute values can be substituted with tokens using the ':value_token' syntax. If tokens are used in the expression then the values or names associated with those tokens must be explicitly added to the expressionValues and expressionNames maps respectively that are also stored on this object.
Example:-
Expression myExpression = Expression.builder() .expression("#a = :b") .putExpressionName("#a", "myAttribute") .putExpressionValue(":b", myAttributeValue) .build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Expression.Builder
A builder forExpression
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Expression
and(Collection<Expression> expressions)
Expression
and(Expression expression)
Coalesces two complete expressions into a single expression joined by an 'AND'.Expression
and(Expression... expressions)
Coalesces multiple complete expressions into a single expression joined by 'AND'.static Expression.Builder
builder()
Constructs a new expression builder.boolean
equals(Object o)
String
expression()
Map<String,String>
expressionNames()
Map<String,AttributeValue>
expressionValues()
int
hashCode()
static Expression
join(String joinToken, Collection<Expression> expressions)
Coalesces multiple complete expressions into a single expression.static Expression
join(String joinToken, Expression... expressions)
static Expression
join(Expression expression1, Expression expression2, String joinToken)
Coalesces two complete expressions into a single expression.static String
joinExpressions(String expression1, String expression2, String joinToken)
Coalesces two expression strings into a single expression string.static Map<String,String>
joinNames(Map<String,String> expressionNames1, Map<String,String> expressionNames2)
Coalesces two ExpressionNames maps into a single ExpressionNames map.static Map<String,AttributeValue>
joinValues(Map<String,AttributeValue> expressionValues1, Map<String,AttributeValue> expressionValues2)
Coalesces two ExpressionValues maps into a single ExpressionValues map.static Expression
or(Collection<Expression> expressions)
Expression
or(Expression... expressions)
Coalesces multiple complete expressions into a single expression joined by 'OR'.
-
-
-
Field Detail
-
AND
public static final String AND
- See Also:
- Constant Field Values
-
OR
public static final String OR
- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static Expression.Builder builder()
Constructs a new expression builder.- Returns:
- a new expression builder.
-
join
public static Expression join(Expression expression1, Expression expression2, String joinToken)
Coalesces two complete expressions into a single expression. The expression string will be joined using the supplied join token, and the ExpressionNames and ExpressionValues maps will be merged.- Parameters:
expression1
- The first expression to coalesceexpression2
- The second expression to coalescejoinToken
- The join token to be used to join the expression strings (e.g.: 'AND', 'OR')- Returns:
- The coalesced expression
- Throws:
IllegalArgumentException
- if a conflict occurs when merging ExpressionNames or ExpressionValues
-
and
public static Expression and(Collection<Expression> expressions)
- See Also:
join(String, Collection)
-
or
public static Expression or(Collection<Expression> expressions)
- See Also:
join(String, Collection)
-
join
public static Expression join(String joinToken, Expression... expressions)
- See Also:
join(String, Collection)
-
join
public static Expression join(String joinToken, Collection<Expression> expressions)
Coalesces multiple complete expressions into a single expression. The expression string will be joined using the supplied join token, and the ExpressionNames and ExpressionValues maps will be merged.- Parameters:
joinToken
- The join token to be used to join the expression strings (e.g.: 'AND', 'OR')expressions
- The expressions to coalesce- Returns:
- The coalesced expression
- Throws:
IllegalArgumentException
- if a conflict occurs when merging ExpressionNames or ExpressionValues
-
joinExpressions
public static String joinExpressions(String expression1, String expression2, String joinToken)
Coalesces two expression strings into a single expression string. The expression string will be joined using the supplied join token.- Parameters:
expression1
- The first expression string to coalesceexpression2
- The second expression string to coalescejoinToken
- The join token to be used to join the expression strings (e.g.: 'AND', 'OR)- Returns:
- The coalesced expression
-
joinValues
public static Map<String,AttributeValue> joinValues(Map<String,AttributeValue> expressionValues1, Map<String,AttributeValue> expressionValues2)
Coalesces two ExpressionValues maps into a single ExpressionValues map. The ExpressionValues map is an optional component of an expression.- Parameters:
expressionValues1
- The first ExpressionValues mapexpressionValues2
- The second ExpressionValues map- Returns:
- The coalesced ExpressionValues map
- Throws:
IllegalArgumentException
- if a conflict occurs when merging ExpressionValues
-
joinNames
public static Map<String,String> joinNames(Map<String,String> expressionNames1, Map<String,String> expressionNames2)
Coalesces two ExpressionNames maps into a single ExpressionNames map. The ExpressionNames map is an optional component of an expression.- Parameters:
expressionNames1
- The first ExpressionNames mapexpressionNames2
- The second ExpressionNames map- Returns:
- The coalesced ExpressionNames map
- Throws:
IllegalArgumentException
- if a conflict occurs when merging ExpressionNames
-
expression
public String expression()
-
expressionValues
public Map<String,AttributeValue> expressionValues()
-
and
public Expression and(Expression expression)
Coalesces two complete expressions into a single expression joined by an 'AND'.- See Also:
join(Expression, Expression, String)
-
and
public Expression and(Expression... expressions)
Coalesces multiple complete expressions into a single expression joined by 'AND'.- See Also:
join(String, Collection)
-
or
public Expression or(Expression... expressions)
Coalesces multiple complete expressions into a single expression joined by 'OR'.- See Also:
join(String, Collection)
-
-