Class Expression
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
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Expression
and
(Collection<Expression> expressions) and
(Expression expression) Coalesces two complete expressions into a single expression joined by an 'AND'.and
(Expression... expressions) Coalesces multiple complete expressions into a single expression joined by 'AND'.static Expression.Builder
builder()
Constructs a new expression builder.boolean
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.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) or
(Expression... expressions) Coalesces multiple complete expressions into a single expression joined by 'OR'.
-
Field Details
-
AND
- See Also:
-
OR
- See Also:
-
-
Method Details
-
builder
Constructs a new expression builder.- Returns:
- a new expression builder.
-
join
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
- See Also:
-
or
- See Also:
-
join
- See Also:
-
join
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
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
-
expressionValues
-
expressionNames
-
and
Coalesces two complete expressions into a single expression joined by an 'AND'.- See Also:
-
and
Coalesces multiple complete expressions into a single expression joined by 'AND'.- See Also:
-
or
Coalesces multiple complete expressions into a single expression joined by 'OR'.- See Also:
-
equals
-
hashCode
public int hashCode()
-