Skip to content

Commit 56fc5bf

Browse files
schaudermp911de
authored andcommitted
DATAJPA-1622 - Removed @Nullable annotation for return types of Specification.
This allows for easier usage as a fluent API without warnings from the IDE or in the case of Kotlin compiler errors. Original pull request: #397.
1 parent 290ca47 commit 56fc5bf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* @author Krzysztof Rzymkowski
3535
* @author Sebastian Staudt
3636
* @author Mark Paluch
37+
* @author Jens Schauder
3738
*/
3839
public interface Specification<T> extends Serializable {
3940

@@ -62,7 +63,6 @@ static <T> Specification<T> not(@Nullable Specification<T> spec) {
6263
* @return
6364
* @since 2.0
6465
*/
65-
@Nullable
6666
static <T> Specification<T> where(@Nullable Specification<T> spec) {
6767
return spec == null ? (root, query, builder) -> null : spec;
6868
}
@@ -74,7 +74,7 @@ static <T> Specification<T> where(@Nullable Specification<T> spec) {
7474
* @return The conjunction of the specifications
7575
* @since 2.0
7676
*/
77-
@Nullable
77+
7878
default Specification<T> and(@Nullable Specification<T> other) {
7979
return composed(this, other, (builder, left, rhs) -> builder.and(left, rhs));
8080
}
@@ -86,7 +86,6 @@ default Specification<T> and(@Nullable Specification<T> other) {
8686
* @return The disjunction of the specifications
8787
* @since 2.0
8888
*/
89-
@Nullable
9089
default Specification<T> or(@Nullable Specification<T> other) {
9190
return composed(this, other, (builder, left, rhs) -> builder.or(left, rhs));
9291
}

src/main/java/org/springframework/data/jpa/domain/SpecificationComposition.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*
3030
* @author Sebastian Staudt
3131
* @author Oliver Gierke
32+
* @author Jens Schauder
3233
* @see Specification
3334
* @since 2.2
3435
*/
@@ -38,7 +39,6 @@ interface Combiner extends Serializable {
3839
Predicate combine(CriteriaBuilder builder, @Nullable Predicate lhs, @Nullable Predicate rhs);
3940
}
4041

41-
@Nullable
4242
static <T> Specification<T> composed(@Nullable Specification<T> lhs, @Nullable Specification<T> rhs,
4343
Combiner combiner) {
4444

@@ -55,7 +55,8 @@ static <T> Specification<T> composed(@Nullable Specification<T> lhs, @Nullable S
5555
};
5656
}
5757

58-
private static <T> Predicate toPredicate(Specification<T> specification, Root<T> root, CriteriaQuery<?> query,
58+
@Nullable
59+
private static <T> Predicate toPredicate(@Nullable Specification<T> specification, Root<T> root, CriteriaQuery<?> query,
5960
CriteriaBuilder builder) {
6061
return specification == null ? null : specification.toPredicate(root, query, builder);
6162
}

0 commit comments

Comments
 (0)