public class ProjectionExpression extends Object
A ProjectionExpression can return a correctly formatted projection expression string
containing placeholder names (see projectionExpressionAsString()
), as well as the expression attribute names map which
contains the mapping from the placeholder attribute name to the actual attribute name (see
expressionAttributeNames()
).
Resolving duplicates
Placeholder conversion examples
#AMZN_MAPPED_MyAttribute
#AMZN_MAPPED_MyAttribute
.#AMZN_MAPPED_MyAttribute_1
#AMZN_MAPPED_0_MyAttribute_1
and
#AMZN_MAPPED_1_MyAttribute_1
List<NestedAttributeName> attributeNames = Arrays.asList(
NestedAttributeName.create("MyAttribute")
NestedAttributeName.create("MyAttribute.WithDot", "MyAttribute.03"),
NestedAttributeName.create("MyAttribute:03, "MyAttribute")
);
ProjectionExpression projectionExpression = ProjectionExpression.create(attributeNames);
Map<String, String> expressionAttributeNames = projectionExpression.expressionAttributeNames();
Optional<String> projectionExpressionString = projectionExpression.projectionExpressionAsString();
results in
expressionAttributeNames: {
#AMZN_MAPPED_MyAttribute : MyAttribute,
#AMZN_MAPPED_MyAttribute_WithDot : MyAttribute.WithDot}
#AMZN_MAPPED_0_MyAttribute_03 : MyAttribute.03}
#AMZN_MAPPED_1_MyAttribute_03 : MyAttribute:03}
}
and
projectionExpressionString: "#AMZN_MAPPED_MyAttribute,#AMZN_MAPPED_MyAttribute_WithDot.#AMZN_MAPPED_0_MyAttribute_03,
#AMZN_MAPPED_1_MyAttribute_03.#AMZN_MAPPED_MyAttribute"
For more information, see Projection Expressions in the Amazon DynamoDB Developer Guide.
Modifier and Type | Method and Description |
---|---|
static ProjectionExpression |
create(List<NestedAttributeName> nestedAttributeNames) |
Map<String,String> |
expressionAttributeNames() |
Optional<String> |
projectionExpressionAsString() |
public static ProjectionExpression create(List<NestedAttributeName> nestedAttributeNames)
Copyright © 2022. All rights reserved.