Skip to content

Backport Specification.unrestricted() from main branch. #3941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public interface Specification<T> extends Serializable {

@Serial long serialVersionUID = 1L;

/**
* Simple static factory method to create a specification matching all objects.
*
* @param <T> the type of the {@link Root} the resulting {@literal Specification} operates on.
* @return guaranteed to be not {@literal null}.
*/
static <T> Specification<T> unrestricted() {
return (root, query, builder) -> null;
}

/**
* Negates the given {@link Specification}.
*
Expand Down Expand Up @@ -72,7 +82,8 @@ static <T> Specification<T> not(@Nullable Specification<T> spec) {
* @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, to be removed with 4.0 as we no longer want to support {@literal null} specifications. Use
* {@link #unrestricted()} instead.
*/
@Deprecated(since = "3.5.0", forRemoval = true)
static <T> Specification<T> where(@Nullable Specification<T> spec) {
Expand Down