Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c91325f

Browse files
committed
Add @CheckReturnValue to Query and Update API.
Closes #1609
1 parent 1a15829 commit c91325f

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

‎spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/query/Columns.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.data.cassandra.core.convert.CassandraVector;
3333
import org.springframework.data.cassandra.core.mapping.SimilarityFunction;
3434
import org.springframework.data.domain.Vector;
35+
import org.springframework.lang.CheckReturnValue;
3536
import org.springframework.util.Assert;
3637
import org.springframework.util.ObjectUtils;
3738
import org.springframework.util.StringUtils;
@@ -113,6 +114,7 @@ public static Columns from(CqlIdentifier... columnNames) {
113114
* @param columnName must not be {@literal null}.
114115
* @return a new {@link Columns} object containing all column definitions and the included {@code columnName}.
115116
*/
117+
@CheckReturnValue
116118
public Columns include(String columnName) {
117119
return select(columnName, ColumnSelector.from(columnName));
118120
}
@@ -124,6 +126,7 @@ public Columns include(String columnName) {
124126
* @param columnName must not be {@literal null}.
125127
* @return a new {@link Columns} object containing all column definitions and the included {@code columnName}.
126128
*/
129+
@CheckReturnValue
127130
public Columns include(CqlIdentifier columnName) {
128131
return select(columnName, ColumnSelector.from(columnName));
129132
}
@@ -135,6 +138,7 @@ public Columns include(CqlIdentifier columnName) {
135138
* @param columnName must not be {@literal null}.
136139
* @return a new {@link Columns} object containing all column definitions and the TTL for {@code columnName}.
137140
*/
141+
@CheckReturnValue
138142
public Columns ttl(String columnName) {
139143
return select(columnName, FunctionCall.from("TTL", ColumnSelector.from(columnName)));
140144
}
@@ -146,6 +150,7 @@ public Columns ttl(String columnName) {
146150
* @param columnName must not be {@literal null}.
147151
* @return a new {@link Columns} object containing all column definitions and the TTL for {@code columnName}.
148152
*/
153+
@CheckReturnValue
149154
public Columns ttl(CqlIdentifier columnName) {
150155
return select(columnName, FunctionCall.from("TTL", ColumnSelector.from(columnName)));
151156
}
@@ -157,6 +162,7 @@ public Columns ttl(CqlIdentifier columnName) {
157162
* @param columnName must not be {@literal null}.
158163
* @return a new {@link Columns} object containing all column definitions and the selected {@code columnName}.
159164
*/
165+
@CheckReturnValue
160166
public Columns select(String columnName, Selector selector) {
161167
return select(ColumnName.from(columnName), selector);
162168
}
@@ -170,6 +176,7 @@ public Columns select(String columnName, Selector selector) {
170176
* @return a new {@link Columns} object containing all column definitions and the selected {@code columnName}.
171177
* @since 4.5
172178
*/
179+
@CheckReturnValue
173180
public Columns select(CqlIdentifier columnName, Function<SelectorBuilder, Selector> builder) {
174181

175182
ColumnName from = ColumnName.from(columnName);
@@ -185,6 +192,7 @@ public Columns select(CqlIdentifier columnName, Function<SelectorBuilder, Select
185192
* @return a new {@link Columns} object containing all column definitions and the selected {@code columnName}.
186193
* @since 4.5
187194
*/
195+
@CheckReturnValue
188196
public Columns select(String columnName, Function<SelectorBuilder, Selector> builder) {
189197

190198
ColumnName from = ColumnName.from(columnName);
@@ -198,6 +206,7 @@ public Columns select(String columnName, Function<SelectorBuilder, Selector> bui
198206
* @param columnName must not be {@literal null}.
199207
* @return a new {@link Columns} object containing all column definitions and the selected {@code columnName}.
200208
*/
209+
@CheckReturnValue
201210
public Columns select(CqlIdentifier columnName, Selector selector) {
202211
return select(ColumnName.from(columnName), selector);
203212
}
@@ -231,6 +240,7 @@ public boolean isEmpty() {
231240
* @param columns must not be {@literal null}.
232241
* @return a new {@link Columns} with the merged result of the configured and given {@link Columns}.
233242
*/
243+
@CheckReturnValue
234244
public Columns and(Columns columns) {
235245

236246
Map<ColumnName, List<Selector>> result = new LinkedHashMap<>(this.columns);

‎spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/query/Criteria.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/**
2727
* Basic class for creating queries. It follows a fluent API style so that you can easily create a
28-
* {@link CriteriaDefinition}. Static import of the 'Criteria.where' method will improve readability.
28+
* {@link CriteriaDefinition}. Static import of the {@code Criteria.where} method will improve readability.
2929
*
3030
* @author Mark Paluch
3131
* @since 2.0

‎spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/query/Query.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.data.domain.Pageable;
3636
import org.springframework.data.domain.Sort;
3737
import org.springframework.data.domain.Sort.Order;
38+
import org.springframework.lang.CheckReturnValue;
3839
import org.springframework.util.Assert;
3940

4041
import com.datastax.oss.driver.api.core.cql.PagingState;
@@ -136,6 +137,7 @@ public static Query query(Iterable<? extends CriteriaDefinition> criteriaDefinit
136137
* @param criteriaDefinition must not be {@literal null}.
137138
* @return a new {@link Query} object containing the former settings with {@link CriteriaDefinition} applied.
138139
*/
140+
@CheckReturnValue
139141
public Query and(CriteriaDefinition criteriaDefinition) {
140142

141143
Assert.notNull(criteriaDefinition, "Criteria must not be null");
@@ -164,6 +166,7 @@ public Iterable<CriteriaDefinition> getCriteriaDefinitions() {
164166
* @param columns must not be {@literal null}.
165167
* @return a new {@link Query} object containing the former settings with {@link Columns} applied.
166168
*/
169+
@CheckReturnValue
167170
public Query columns(Columns columns) {
168171

169172
Assert.notNull(columns, "Columns must not be null");
@@ -185,6 +188,7 @@ public Columns getColumns() {
185188
* @param sort must not be {@literal null}.
186189
* @return a new {@link Query} object containing the former settings with {@link Sort} applied.
187190
*/
191+
@CheckReturnValue
188192
public Query sort(Sort sort) {
189193

190194
Assert.notNull(sort, "Sort must not be null");
@@ -226,6 +230,7 @@ public Sort getSort() {
226230
* @return a new {@link Query} object containing the former settings with {@link PageRequest} applied.
227231
* @see CassandraPageRequest
228232
*/
233+
@CheckReturnValue
229234
public Query pageRequest(Pageable pageable) {
230235

231236
Assert.notNull(pageable, "Pageable must not be null");
@@ -255,6 +260,7 @@ public Query pageRequest(Pageable pageable) {
255260
* @param scrollPosition must not be {@literal null}.
256261
* @return a new {@link Query} object containing the former settings with paging state applied.
257262
*/
263+
@CheckReturnValue
258264
public Query pagingState(CassandraScrollPosition scrollPosition) {
259265

260266
Assert.notNull(scrollPosition, "CassandraScrollPosition must not be null");
@@ -270,6 +276,7 @@ public Query pagingState(CassandraScrollPosition scrollPosition) {
270276
* @return a new {@link Query} object containing the former settings with {@link PagingState paging state} applied.
271277
* @since 5.0
272278
*/
279+
@CheckReturnValue
273280
public Query pagingState(PagingState pagingState) {
274281
return pagingState(CassandraScrollPosition.of(pagingState));
275282
}
@@ -280,6 +287,7 @@ public Query pagingState(PagingState pagingState) {
280287
* @param pagingState must not be {@literal null}.
281288
* @return a new {@link Query} object containing the former settings with {@link ByteBuffer paging state} applied.
282289
*/
290+
@CheckReturnValue
283291
public Query pagingState(ByteBuffer pagingState) {
284292

285293
Assert.notNull(pagingState, "PagingState must not be null");
@@ -306,6 +314,7 @@ public Optional<ByteBuffer> getPagingState() {
306314
* @param queryOptions must not be {@literal null}.
307315
* @return a new {@link Query} object containing the former settings with {@link QueryOptions} applied.
308316
*/
317+
@CheckReturnValue
309318
public Query queryOptions(QueryOptions queryOptions) {
310319

311320
Assert.notNull(queryOptions, "QueryOptions must not be null");
@@ -327,6 +336,7 @@ public Optional<QueryOptions> getQueryOptions() {
327336
* @param limit
328337
* @return a new {@link Query} object containing the former settings with {@code limit} applied.
329338
*/
339+
@CheckReturnValue
330340
public Query limit(long limit) {
331341
return new Query(this.criteriaDefinitions, this.columns, this.sort, this.scrollPosition, this.queryOptions,
332342
Limit.of(Math.toIntExact(limit)), this.allowFiltering);
@@ -338,6 +348,7 @@ public Query limit(long limit) {
338348
* @param limit
339349
* @return a new {@link Query} object containing the former settings with {@code limit} applied.
340350
*/
351+
@CheckReturnValue
341352
public Query limit(Limit limit) {
342353
return new Query(this.criteriaDefinitions, this.columns, this.sort, this.scrollPosition, this.queryOptions, limit,
343354
this.allowFiltering);
@@ -362,6 +373,7 @@ public boolean isLimited() {
362373
*
363374
* @return a new {@link Query} object containing the former settings with {@code allowFiltering} applied.
364375
*/
376+
@CheckReturnValue
365377
public Query withAllowFiltering() {
366378
return new Query(this.criteriaDefinitions, this.columns, this.sort, this.scrollPosition, this.queryOptions,
367379
this.limit, true);

‎spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/query/Update.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.jspecify.annotations.Nullable;
2828

2929
import org.springframework.data.cassandra.core.query.Update.AddToOp.Mode;
30+
import org.springframework.lang.CheckReturnValue;
3031
import org.springframework.util.Assert;
3132
import org.springframework.util.ObjectUtils;
3233
import org.springframework.util.StringUtils;
@@ -98,6 +99,7 @@ private Update(List<AssignmentOp> updateOperations) {
9899
* @return a new {@link Update} object containing the merge result of the existing assignments and the current
99100
* assignment.
100101
*/
102+
@CheckReturnValue
101103
public Update set(String columnName, @Nullable Object value) {
102104
return add(new SetOp(ColumnName.from(columnName), value));
103105
}
@@ -106,8 +108,9 @@ public Update set(String columnName, @Nullable Object value) {
106108
* Create a new {@link SetBuilder} to set a collection item for {@code columnName} in a fluent style.
107109
*
108110
* @param columnName must not be {@literal null}.
109-
* @return a new {@link AddToBuilder} to build an set assignment.
111+
* @return a new {@link AddToBuilder} to build a set assignment.
110112
*/
113+
@CheckReturnValue
111114
public SetBuilder set(String columnName) {
112115
return new DefaultSetBuilder(ColumnName.from(columnName));
113116
}
@@ -118,6 +121,7 @@ public SetBuilder set(String columnName) {
118121
* @param columnName must not be {@literal null}.
119122
* @return a new {@link AddToBuilder} to build an add-to assignment.
120123
*/
124+
@CheckReturnValue
121125
public AddToBuilder addTo(String columnName) {
122126
return new DefaultAddToBuilder(ColumnName.from(columnName));
123127
}
@@ -129,6 +133,7 @@ public AddToBuilder addTo(String columnName) {
129133
* @return a new {@link RemoveFromBuilder} to build an remove-from assignment.
130134
* @since 3.1.4
131135
*/
136+
@CheckReturnValue
132137
public RemoveFromBuilder removeFrom(String columnName) {
133138
return new DefaultRemoveFromBuilder(ColumnName.from(columnName));
134139
}
@@ -141,6 +146,7 @@ public RemoveFromBuilder removeFrom(String columnName) {
141146
* @return a new {@link Update} object containing the merge result of the existing assignments and the current
142147
* assignment.
143148
*/
149+
@CheckReturnValue
144150
public Update remove(String columnName, Object value) {
145151
return add(new RemoveOp(ColumnName.from(columnName), Collections.singletonList(value)));
146152
}
@@ -152,6 +158,7 @@ public Update remove(String columnName, Object value) {
152158
* @return a new {@link Update} object containing the merge result of the existing assignments and the current
153159
* assignment.
154160
*/
161+
@CheckReturnValue
155162
public Update clear(String columnName) {
156163
return add(new SetOp(ColumnName.from(columnName), Collections.emptyList()));
157164
}
@@ -163,6 +170,7 @@ public Update clear(String columnName) {
163170
* @return a new {@link Update} object containing the merge result of the existing assignments and the current
164171
* assignment.
165172
*/
173+
@CheckReturnValue
166174
public Update increment(String columnName) {
167175
return increment(columnName, 1);
168176
}
@@ -175,6 +183,7 @@ public Update increment(String columnName) {
175183
* @return a new {@link Update} object containing the merge result of the existing assignments and the current
176184
* assignment.
177185
*/
186+
@CheckReturnValue
178187
public Update increment(String columnName, Number delta) {
179188
return add(new IncrOp(ColumnName.from(columnName), delta));
180189
}
@@ -186,6 +195,7 @@ public Update increment(String columnName, Number delta) {
186195
* @return a new {@link Update} object containing the merge result of the existing assignments and the current
187196
* assignment.
188197
*/
198+
@CheckReturnValue
189199
public Update decrement(String columnName) {
190200
return decrement(columnName, 1);
191201
}
@@ -198,6 +208,7 @@ public Update decrement(String columnName) {
198208
* @return a new {@link Update} object containing the merge result of the existing assignments and the current
199209
* assignment.
200210
*/
211+
@CheckReturnValue
201212
public Update decrement(String columnName, Number delta) {
202213

203214
if (delta instanceof Integer || delta instanceof Long) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /