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.
This commit is contained in:
Jens Schauder
2019-11-06 10:59:15 +01:00
committed by Mark Paluch
parent 7d1561b1b0
commit ca8a8d60b0
2 changed files with 5 additions and 5 deletions

View File

@@ -34,6 +34,7 @@ import org.springframework.lang.Nullable;
* @author Krzysztof Rzymkowski
* @author Sebastian Staudt
* @author Mark Paluch
* @author Jens Schauder
*/
public interface Specification<T> extends Serializable {
@@ -62,7 +63,6 @@ public interface Specification<T> extends Serializable {
* @return
* @since 2.0
*/
@Nullable
static <T> Specification<T> where(@Nullable Specification<T> spec) {
return spec == null ? (root, query, builder) -> null : spec;
}
@@ -74,7 +74,7 @@ public interface Specification<T> extends Serializable {
* @return The conjunction of the specifications
* @since 2.0
*/
@Nullable
default Specification<T> and(@Nullable Specification<T> other) {
return composed(this, other, (builder, left, rhs) -> builder.and(left, rhs));
}
@@ -86,7 +86,6 @@ public interface Specification<T> extends Serializable {
* @return The disjunction of the specifications
* @since 2.0
*/
@Nullable
default Specification<T> or(@Nullable Specification<T> other) {
return composed(this, other, (builder, left, rhs) -> builder.or(left, rhs));
}

View File

@@ -29,6 +29,7 @@ import org.springframework.lang.Nullable;
*
* @author Sebastian Staudt
* @author Oliver Gierke
* @author Jens Schauder
* @see Specification
* @since 2.2
*/
@@ -38,7 +39,6 @@ class SpecificationComposition {
Predicate combine(CriteriaBuilder builder, @Nullable Predicate lhs, @Nullable Predicate rhs);
}
@Nullable
static <T> Specification<T> composed(@Nullable Specification<T> lhs, @Nullable Specification<T> rhs,
Combiner combiner) {
@@ -55,7 +55,8 @@ class SpecificationComposition {
};
}
private static <T> Predicate toPredicate(Specification<T> specification, Root<T> root, CriteriaQuery<?> query,
@Nullable
private static <T> Predicate toPredicate(@Nullable Specification<T> specification, Root<T> root, CriteriaQuery<?> query,
CriteriaBuilder builder) {
return specification == null ? null : specification.toPredicate(root, query, builder);
}