24
24
import java .util .Arrays ;
25
25
import java .util .stream .StreamSupport ;
26
26
27
+ import org .springframework .lang .CheckReturnValue ;
28
+ import org .springframework .lang .Contract ;
27
29
import org .springframework .lang .Nullable ;
28
30
import org .springframework .util .Assert ;
29
31
30
32
/**
31
33
* Specification in the sense of Domain Driven Design to handle Criteria Updates.
32
34
*
33
35
* @author Mark Paluch
34
- * @since xxx
36
+ * @since 4.0
35
37
*/
36
38
@ FunctionalInterface
37
39
public interface UpdateSpecification <T > extends Serializable {
@@ -103,6 +105,8 @@ static <T> UpdateSpecification<T> where(PredicateSpecification<T> spec) {
103
105
* @param other the other {@link UpdateSpecification}.
104
106
* @return the conjunction of the specifications.
105
107
*/
108
+ @ Contract ("_ -> new" )
109
+ @ CheckReturnValue
106
110
default UpdateSpecification <T > and (UpdateSpecification <T > other ) {
107
111
108
112
Assert .notNull (other , "Other specification must not be null" );
@@ -116,6 +120,8 @@ default UpdateSpecification<T> and(UpdateSpecification<T> other) {
116
120
* @param other the other {@link PredicateSpecification}.
117
121
* @return the conjunction of the specifications.
118
122
*/
123
+ @ Contract ("_ -> new" )
124
+ @ CheckReturnValue
119
125
default UpdateSpecification <T > and (PredicateSpecification <T > other ) {
120
126
121
127
Assert .notNull (other , "Other specification must not be null" );
@@ -129,6 +135,8 @@ default UpdateSpecification<T> and(PredicateSpecification<T> other) {
129
135
* @param other the other {@link UpdateSpecification}.
130
136
* @return the disjunction of the specifications.
131
137
*/
138
+ @ Contract ("_ -> new" )
139
+ @ CheckReturnValue
132
140
default UpdateSpecification <T > or (UpdateSpecification <T > other ) {
133
141
134
142
Assert .notNull (other , "Other specification must not be null" );
@@ -142,6 +150,8 @@ default UpdateSpecification<T> or(UpdateSpecification<T> other) {
142
150
* @param other the other {@link PredicateSpecification}.
143
151
* @return the disjunction of the specifications.
144
152
*/
153
+ @ Contract ("_ -> new" )
154
+ @ CheckReturnValue
145
155
default UpdateSpecification <T > or (PredicateSpecification <T > other ) {
146
156
147
157
Assert .notNull (other , "Other specification must not be null" );
@@ -256,6 +266,8 @@ interface UpdateOperation<T> {
256
266
* @param other the other {@link UpdateOperation}.
257
267
* @return the conjunction of the specifications.
258
268
*/
269
+ @ Contract ("_ -> new" )
270
+ @ CheckReturnValue
259
271
default UpdateOperation <T > and (UpdateOperation <T > other ) {
260
272
261
273
Assert .notNull (other , "Other UpdateOperation must not be null" );
@@ -272,6 +284,8 @@ default UpdateOperation<T> and(UpdateOperation<T> other) {
272
284
* @param specification the {@link PredicateSpecification}.
273
285
* @return the conjunction of the specifications.
274
286
*/
287
+ @ Contract ("_ -> new" )
288
+ @ CheckReturnValue
275
289
default UpdateSpecification <T > where (PredicateSpecification <T > specification ) {
276
290
277
291
Assert .notNull (specification , "PredicateSpecification must not be null" );
@@ -288,6 +302,8 @@ default UpdateSpecification<T> where(PredicateSpecification<T> specification) {
288
302
* @param specification the {@link UpdateSpecification}.
289
303
* @return the conjunction of the specifications.
290
304
*/
305
+ @ Contract ("_ -> new" )
306
+ @ CheckReturnValue
291
307
default UpdateSpecification <T > where (UpdateSpecification <T > specification ) {
292
308
293
309
Assert .notNull (specification , "UpdateSpecification must not be null" );
@@ -306,6 +322,7 @@ default UpdateSpecification<T> where(UpdateSpecification<T> specification) {
306
322
* @param criteriaBuilder must not be {@literal null}.
307
323
*/
308
324
void apply (Root <T > root , CriteriaUpdate <T > update , CriteriaBuilder criteriaBuilder );
325
+
309
326
}
310
327
311
328
}
0 commit comments