34
34
import software .amazon .awssdk .services .dynamodb .model .QueryRequest ;
35
35
import software .amazon .awssdk .services .dynamodb .model .ReturnConsumedCapacity ;
36
36
import software .amazon .awssdk .services .dynamodb .model .ScanRequest ;
37
+ import software .amazon .awssdk .services .dynamodb .model .Select ;
37
38
import software .amazon .awssdk .utils .Validate ;
38
39
39
40
/**
@@ -52,6 +53,7 @@ public final class QueryEnhancedRequest {
52
53
private final QueryConditional queryConditional ;
53
54
private final Map <String , AttributeValue > exclusiveStartKey ;
54
55
private final Boolean scanIndexForward ;
56
+ private final Select select ;
55
57
private final Integer limit ;
56
58
private final Boolean consistentRead ;
57
59
private final Expression filterExpression ;
@@ -62,13 +64,14 @@ private QueryEnhancedRequest(Builder builder) {
62
64
this .queryConditional = builder .queryConditional ;
63
65
this .exclusiveStartKey = builder .exclusiveStartKey ;
64
66
this .scanIndexForward = builder .scanIndexForward ;
67
+ this .select = builder .select ;
65
68
this .limit = builder .limit ;
66
69
this .consistentRead = builder .consistentRead ;
67
70
this .filterExpression = builder .filterExpression ;
68
71
this .returnConsumedCapacity = builder .returnConsumedCapacity ;
69
72
this .attributesToProject = builder .attributesToProject != null
70
- ? Collections .unmodifiableList (builder .attributesToProject )
71
- : null ;
73
+ ? Collections .unmodifiableList (builder .attributesToProject )
74
+ : null ;
72
75
}
73
76
74
77
/**
@@ -85,6 +88,7 @@ public Builder toBuilder() {
85
88
return builder ().queryConditional (queryConditional )
86
89
.exclusiveStartKey (exclusiveStartKey )
87
90
.scanIndexForward (scanIndexForward )
91
+ .select (select )
88
92
.limit (limit )
89
93
.consistentRead (consistentRead )
90
94
.filterExpression (filterExpression )
@@ -114,6 +118,22 @@ public Boolean scanIndexForward() {
114
118
return scanIndexForward ;
115
119
}
116
120
121
+ /**
122
+ * Returns the value of select, or null if it doesn't exist.
123
+ * @return
124
+ */
125
+ public Select select () {
126
+ return select ;
127
+ }
128
+
129
+ /**
130
+ * Returns the value of select as a string, or null if it doesn't exist.
131
+ * @return
132
+ */
133
+ public String selectAsString () {
134
+ return String .valueOf (select );
135
+ }
136
+
117
137
/**
118
138
* Returns the value of limit set on this request object, or null if it doesn't exist.
119
139
*/
@@ -143,7 +163,8 @@ public Expression filterExpression() {
143
163
*/
144
164
public List <String > attributesToProject () {
145
165
return attributesToProject != null ? attributesToProject .stream ()
146
- .map (item -> String .join ("." , item .elements ())).collect (Collectors .toList ()) : null ;
166
+ .map (item -> String .join ("." , item .elements ()))
167
+ .collect (Collectors .toList ()) : null ;
147
168
}
148
169
149
170
/**
@@ -198,14 +219,20 @@ public boolean equals(Object o) {
198
219
query .scanIndexForward != null ) {
199
220
return false ;
200
221
}
222
+
223
+ if (select != null ? ! select .equals (query .select ) :
224
+ query .select != null ) {
225
+ return false ;
226
+ }
227
+
201
228
if (limit != null ? ! limit .equals (query .limit ) : query .limit != null ) {
202
229
return false ;
203
230
}
204
231
if (consistentRead != null ? ! consistentRead .equals (query .consistentRead ) : query .consistentRead != null ) {
205
232
return false ;
206
233
}
207
234
if (attributesToProject != null
208
- ? !attributesToProject .equals (query .attributesToProject ) : query .attributesToProject != null ) {
235
+ ? !attributesToProject .equals (query .attributesToProject ) : query .attributesToProject != null ) {
209
236
return false ;
210
237
}
211
238
if (returnConsumedCapacity != null
@@ -220,6 +247,7 @@ public int hashCode() {
220
247
int result = queryConditional != null ? queryConditional .hashCode () : 0 ;
221
248
result = 31 * result + (exclusiveStartKey != null ? exclusiveStartKey .hashCode () : 0 );
222
249
result = 31 * result + (scanIndexForward != null ? scanIndexForward .hashCode () : 0 );
250
+ result = 31 * result + (select != null ? select .hashCode () : 0 );
223
251
result = 31 * result + (limit != null ? limit .hashCode () : 0 );
224
252
result = 31 * result + (consistentRead != null ? consistentRead .hashCode () : 0 );
225
253
result = 31 * result + (filterExpression != null ? filterExpression .hashCode () : 0 );
@@ -238,6 +266,7 @@ public static final class Builder {
238
266
private QueryConditional queryConditional ;
239
267
private Map <String , AttributeValue > exclusiveStartKey ;
240
268
private Boolean scanIndexForward ;
269
+ private Select select ;
241
270
private Integer limit ;
242
271
private Boolean consistentRead ;
243
272
private Expression filterExpression ;
@@ -271,6 +300,17 @@ public Builder scanIndexForward(Boolean scanIndexForward) {
271
300
return this ;
272
301
}
273
302
303
+ /**
304
+ * Determines the attributes to be returned in the result. See {@link Select} for examples and constraints.
305
+ * By default, all attributes are returned.
306
+ * @param select
307
+ * @return a builder of this type
308
+ */
309
+ public Builder select (Select select ) {
310
+ this .select = select ;
311
+ return this ;
312
+ }
313
+
274
314
/**
275
315
* The primary key of the first item that this operation will evaluate. By default, the operation will evaluate
276
316
* the whole dataset. If used, normally this parameter is populated with the value that was returned for
@@ -353,8 +393,10 @@ public Builder attributesToProject(Collection<String> attributesToProject) {
353
393
this .attributesToProject .clear ();
354
394
}
355
395
if (attributesToProject != null ) {
356
- addNestedAttributesToProject (new ArrayList <>(attributesToProject ).stream ()
357
- .map (NestedAttributeName ::create ).collect (Collectors .toList ()));
396
+ addNestedAttributesToProject (new ArrayList <>(attributesToProject )
397
+ .stream ()
398
+ .map (NestedAttributeName ::create )
399
+ .collect (Collectors .toList ()));
358
400
}
359
401
return this ;
360
402
}
@@ -409,7 +451,7 @@ public Builder addAttributeToProject(String attributeToProject) {
409
451
public Builder addNestedAttributesToProject (Collection <NestedAttributeName > nestedAttributeNames ) {
410
452
if (nestedAttributeNames != null ) {
411
453
Validate .noNullElements (nestedAttributeNames ,
412
- "nestedAttributeNames list must not contain null elements" );
454
+ "nestedAttributeNames list must not contain null elements" );
413
455
if (attributesToProject == null ) {
414
456
this .attributesToProject = new ArrayList <>(nestedAttributeNames );
415
457
} else {
0 commit comments