Skip to content

Commit a9813a7

Browse files
committed
Document deprecation of Specification.where(…).
Also, document the intent to make methods accepting `Specifications` to be non-nullable. Closes #3893
1 parent 42463ae commit a9813a7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/Specification.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public interface Specification<T> extends Serializable {
4747
/**
4848
* Negates the given {@link Specification}.
4949
*
50+
* @apiNote with 4.0, this method will no longer accept {@literal null} specifications.
5051
* @param <T> the type of the {@link Root} the resulting {@literal Specification} operates on.
5152
* @param spec can be {@literal null}.
5253
* @return guaranteed to be not {@literal null}.
@@ -58,19 +59,20 @@ static <T> Specification<T> not(@Nullable Specification<T> spec) {
5859
? (root, query, builder) -> null //
5960
: (root, query, builder) -> {
6061

61-
Predicate predicate = spec.toPredicate(root, query, builder);
62+
Predicate predicate = spec.toPredicate(root, query, builder);
6263
return predicate != null ? builder.not(predicate) : builder.disjunction();
63-
};
64+
};
6465
}
6566

6667
/**
6768
* Simple static factory method to add some syntactic sugar around a {@link Specification}.
6869
*
70+
* @apiNote with 4.0, this method will no longer accept {@literal null} specifications.
6971
* @param <T> the type of the {@link Root} the resulting {@literal Specification} operates on.
7072
* @param spec can be {@literal null}.
7173
* @return guaranteed to be not {@literal null}.
7274
* @since 2.0
73-
* @deprecated since 3.5.
75+
* @deprecated since 3.5, to be removed with 4.0 as we no longer want to support {@literal null} specifications.
7476
*/
7577
@Deprecated(since = "3.5.0", forRemoval = true)
7678
static <T> Specification<T> where(@Nullable Specification<T> spec) {
@@ -80,6 +82,7 @@ static <T> Specification<T> where(@Nullable Specification<T> spec) {
8082
/**
8183
* ANDs the given {@link Specification} to the current one.
8284
*
85+
* @apiNote with 4.0, this method will no longer accept {@literal null} specifications.
8386
* @param other can be {@literal null}.
8487
* @return The conjunction of the specifications
8588
* @since 2.0
@@ -91,6 +94,7 @@ default Specification<T> and(@Nullable Specification<T> other) {
9194
/**
9295
* ORs the given specification to the current one.
9396
*
97+
* @apiNote with 4.0, this method will no longer accept {@literal null} specifications.
9498
* @param other can be {@literal null}.
9599
* @return The disjunction of the specifications
96100
* @since 2.0
@@ -104,7 +108,9 @@ default Specification<T> or(@Nullable Specification<T> other) {
104108
* {@link Root} and {@link CriteriaQuery}.
105109
*
106110
* @param root must not be {@literal null}.
107-
* @param query can be {@literal null} to allow overrides that accept {@link jakarta.persistence.criteria.CriteriaDelete} which is an {@link jakarta.persistence.criteria.AbstractQuery} but no {@link CriteriaQuery}.
111+
* @param query can be {@literal null} to allow overrides that accept
112+
* {@link jakarta.persistence.criteria.CriteriaDelete} which is an
113+
* {@link jakarta.persistence.criteria.AbstractQuery} but no {@link CriteriaQuery}.
108114
* @param criteriaBuilder must not be {@literal null}.
109115
* @return a {@link Predicate}, may be {@literal null}.
110116
*/

0 commit comments

Comments
 (0)