Class ProjectionExpression
java.lang.Object
dev.hogwai.dynamodb.simplified.expression.ProjectionExpression
Fluent builder for constructing DynamoDB projection expressions as part of
the DynamoDB Simplified library.
A projection expression specifies the attributes to retrieve from a DynamoDB
table or index, reducing the data returned by Scan, Query,
or GetItem operations. This builder automatically maps attribute
names to expression attribute name placeholders (#p0, #p1, ...)
to avoid reserved word conflicts. Supports top-level attributes, nested
attribute paths (e.g., address.city), and list element access
(e.g., items[0]).
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull ProjectionExpressionbuilder()Creates a newProjectionExpressionbuilder.@NonNull StringReturns the built projection expression string, a comma-separated list of attribute references (e.g.,"#p0, #p1, #p2[0]").Returns the map of expression attribute names used in this expression.Returns the raw attribute paths as they were added by the user.@NonNull ProjectionExpressionIncludes one or more top-level attribute names in the projection.@NonNull ProjectionExpressionincludeListElement(@NonNull String attribute, int index) Includes a specific list element in the projection (e.g.@NonNull ProjectionExpressionincludeNested(@NonNull String path) Includes a nested attribute path in the projection (e.g.booleanisEmpty()Returns whether no attributes have been added to this projection yet.
-
Method Details
-
builder
Creates a newProjectionExpressionbuilder.- Returns:
- a new empty
ProjectionExpression
-
include
Includes one or more top-level attribute names in the projection. Each attribute is automatically mapped to an expression attribute name placeholder.- Parameters:
attributes- one or more attribute names to include- Returns:
- this builder for chaining
-
includeNested
Includes a nested attribute path in the projection (e.g."address.city"). Each path segment is mapped to an expression attribute name placeholder.- Parameters:
path- the dotted nested attribute path- Returns:
- this builder for chaining
-
includeListElement
Includes a specific list element in the projection (e.g."items[0]).- Parameters:
attribute- the attribute nameindex- the zero-based element index- Returns:
- this builder for chaining
-
getExpression
Returns the built projection expression string, a comma-separated list of attribute references (e.g.,"#p0, #p1, #p2[0]").- Returns:
- the projection expression string
-
getExpressionNames
-
isEmpty
public boolean isEmpty()Returns whether no attributes have been added to this projection yet.- Returns:
trueif the projection is empty,falseotherwise
-
getProjectedAttributes
Returns the raw attribute paths as they were added by the user.These are the original attribute names and paths (e.g.,
"address.city") rather than the expression placeholder forms (e.g.,"#p0.#p1"). Use this when passing projection attributes directly to the DynamoDB SDK'sattributesToProjectmethod.- Returns:
- list of raw attribute paths
-