/**
* Simple static factory method to add some syntactic sugar around a {@link Specification}.
*
* @apiNote with 4.0, this method will no longer accept {@literal null} specifications.
* @param <T> the type of the {@link Root} the resulting {@literal Specification} operates on.
* @param spec can be {@literal null}.
* @return guaranteed to be not {@literal null}.
* @since 2.0
* @deprecated since 3.5, to be removed with 4.0 as we no longer want to support {@literal null} specifications.
*/
@Deprecated(since = "3.5.0", forRemoval = true)
static <T> Specification<T> where(@Nullable Specification<T> spec) {
return spec == null ? (root, query, builder) -> null : spec;
}
非推奨になったけれども、まだ代替手段はないようだ。Nullを許容しなくなることを警告するためのものらしい。
The where method merely caters for the broken nullability allowance and is replaced by where(PredicateSpecification) in 4.0.
まだ確定ではないかもしれないが、mainでは下記の様に修正されている。
/**
* Simple static factory method to add some syntactic sugar translating {@link PredicateSpecification} to
* {@link Specification}.
*
* @param <T> the type of the {@link Root} the resulting {@literal Specification} operates on.
* @param spec the {@link PredicateSpecification} to wrap.
* @return guaranteed to be not {@literal null}.
*/
static <T> Specification<T> where(PredicateSpecification<T> spec) {
Assert.notNull(spec, "PredicateSpecification must not be null");
return (root, update, criteriaBuilder) -> spec.toPredicate(root, criteriaBuilder);
}
@Deprecatedを付けるのはまだ早かったのではないだろうか。(同じようにNullを許容しなくなる他のメソッドにはついていないし)