Interface DeleteSpecification<T>
- All Superinterfaces:
Serializable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Specification in the sense of Domain Driven Design to handle Criteria Deletes.
Specifications can be composed into higher order functions from other specifications using
and(DeleteSpecification), or(DeleteSpecification) or factory methods such as
allOf(Iterable). Composition considers whether one or more specifications contribute to the overall
predicate by returning a Predicate or null. Specifications returning null are
considered to not contribute to the overall predicate and their result is not considered in the final predicate.
- Since:
- 4.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> DeleteSpecification<T>allOf(Iterable<DeleteSpecification<T>> specifications) Applies an AND operation to all the givenDeleteSpecifications.static <T> DeleteSpecification<T>allOf(DeleteSpecification<T>... specifications) Applies an AND operation to all the givenDeleteSpecifications.default DeleteSpecification<T>and(DeleteSpecification<T> other) ANDs the givenDeleteSpecificationto the current one.default DeleteSpecification<T>and(PredicateSpecification<T> other) ANDs the givenDeleteSpecificationto the current one.static <T> DeleteSpecification<T>anyOf(Iterable<DeleteSpecification<T>> specifications) Applies an OR operation to all the givenDeleteSpecifications.static <T> DeleteSpecification<T>anyOf(DeleteSpecification<T>... specifications) Applies an OR operation to all the givenDeleteSpecifications.static <T> DeleteSpecification<T>not(DeleteSpecification<T> spec) Negates the givenDeleteSpecification.default DeleteSpecification<T>or(DeleteSpecification<T> other) ORs the given specification to the current one.default DeleteSpecification<T>or(PredicateSpecification<T> other) ORs the given specification to the current one.@Nullable jakarta.persistence.criteria.PredicatetoPredicate(jakarta.persistence.criteria.Root<T> root, jakarta.persistence.criteria.CriteriaDelete<T> delete, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) Creates a WHERE clause for a query of the referenced entity in form of aPredicatefor the givenRootandCriteriaDelete.static <T> DeleteSpecification<T>Simple static factory method to create a specification deleting all objects.static <T> DeleteSpecification<T>where(DeleteSpecification<T> spec) Simple static factory method to add some syntactic sugar around a DeleteSpecification.static <T> DeleteSpecification<T>where(PredicateSpecification<T> spec) Simple static factory method to add some syntactic sugar translatingPredicateSpecificationtoDeleteSpecification.
-
Method Details
-
unrestricted
Simple static factory method to create a specification deleting all objects.- Type Parameters:
T- the type of theRootthe resulting DeleteSpecification operates on.- Returns:
- guaranteed to be not null.
-
where
Simple static factory method to add some syntactic sugar around a DeleteSpecification.- Type Parameters:
T- the type of theRootthe resulting DeleteSpecification operates on.- Parameters:
spec- must not be null.- Returns:
- guaranteed to be not null.
-
where
Simple static factory method to add some syntactic sugar translatingPredicateSpecificationtoDeleteSpecification.- Type Parameters:
T- the type of theRootthe resulting DeleteSpecification operates on.- Parameters:
spec- thePredicateSpecificationto wrap.- Returns:
- guaranteed to be not null.
-
and
@Contract("_ -> new") @CheckReturnValue default DeleteSpecification<T> and(DeleteSpecification<T> other) ANDs the givenDeleteSpecificationto the current one.- Parameters:
other- the otherDeleteSpecification.- Returns:
- the conjunction of the specifications.
-
and
@Contract("_ -> new") @CheckReturnValue default DeleteSpecification<T> and(PredicateSpecification<T> other) ANDs the givenDeleteSpecificationto the current one.- Parameters:
other- the otherPredicateSpecification.- Returns:
- the conjunction of the specifications.
-
or
@Contract("_ -> new") @CheckReturnValue default DeleteSpecification<T> or(DeleteSpecification<T> other) ORs the given specification to the current one.- Parameters:
other- the otherDeleteSpecification.- Returns:
- the disjunction of the specifications.
-
or
@Contract("_ -> new") @CheckReturnValue default DeleteSpecification<T> or(PredicateSpecification<T> other) ORs the given specification to the current one.- Parameters:
other- the otherPredicateSpecification.- Returns:
- the disjunction of the specifications.
-
not
Negates the givenDeleteSpecification.- Type Parameters:
T- the type of theRootthe resulting DeleteSpecification operates on.- Parameters:
spec- can be null.- Returns:
- guaranteed to be not null.
-
allOf
Applies an AND operation to all the givenDeleteSpecifications. Ifspecificationsis empty, the resultingDeleteSpecificationwill be unrestricted applying to all objects.- Parameters:
specifications- theDeleteSpecifications to compose.- Returns:
- the conjunction of the specifications.
- See Also:
-
allOf
Applies an AND operation to all the givenDeleteSpecifications. Ifspecificationsis empty, the resultingDeleteSpecificationwill be unrestricted applying to all objects.- Parameters:
specifications- theDeleteSpecifications to compose.- Returns:
- the conjunction of the specifications.
- See Also:
-
anyOf
Applies an OR operation to all the givenDeleteSpecifications. Ifspecificationsis empty, the resultingDeleteSpecificationwill be unrestricted applying to all objects.- Parameters:
specifications- theDeleteSpecifications to compose.- Returns:
- the disjunction of the specifications.
- See Also:
-
anyOf
Applies an OR operation to all the givenDeleteSpecifications. Ifspecificationsis empty, the resultingDeleteSpecificationwill be unrestricted applying to all objects.- Parameters:
specifications- theDeleteSpecifications to compose.- Returns:
- the disjunction of the specifications.
- See Also:
-
toPredicate
@Nullable jakarta.persistence.criteria.Predicate toPredicate(jakarta.persistence.criteria.Root<T> root, jakarta.persistence.criteria.CriteriaDelete<T> delete, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) Creates a WHERE clause for a query of the referenced entity in form of aPredicatefor the givenRootandCriteriaDelete.- Parameters:
root- must not be null.delete- the delete criteria.criteriaBuilder- must not be null.- Returns:
- a
Predicate, may be null.
-