Interface Specification<T>
-
- Type Parameters:
T- The entity root type
public interface Specification<T>Specification in the sense of Domain Driven Design. Fork fromSpecification.- Since:
- 3.1
- Author:
- Oliver Gierke, Thomas Darimont, Krzysztof Rzymkowski, Sebastian Staudt, Mark Paluch, Jens Schauder
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Specification<T>and(Specification<T> other)ANDs the givenSpecificationto the current one.static <T> Specification<T>not(Specification<T> spec)Negates the givenSpecification.default Specification<T>or(Specification<T> other)ORs the given specification to the current one.javax.persistence.criteria.PredicatetoPredicate(javax.persistence.criteria.Root<T> root, javax.persistence.criteria.CriteriaQuery<?> query, javax.persistence.criteria.CriteriaBuilder criteriaBuilder)Creates a WHERE clause for a query of the referenced entity in form of aPredicatefor the givenRootandCriteriaQuery.static <T> Specification<T>where(Specification<T> spec)Simple static factory method to add some syntactic sugar around aSpecification.
-
-
-
Method Detail
-
not
@NonNull static <T> Specification<T> not(@Nullable Specification<T> spec)
Negates the givenSpecification.- Type Parameters:
T- the type of theRootthe resulting Specification operates on.- Parameters:
spec- can be null.- Returns:
- guaranteed to be not null.
-
where
@NonNull static <T> Specification<T> where(@Nullable Specification<T> spec)
Simple static factory method to add some syntactic sugar around aSpecification.- Type Parameters:
T- the type of theRootthe resulting Specification operates on.- Parameters:
spec- can be null.- Returns:
- guaranteed to be not null.
-
and
@NonNull default Specification<T> and(@Nullable Specification<T> other)
ANDs the givenSpecificationto the current one.- Parameters:
other- can be null.- Returns:
- The conjunction of the specifications
-
or
@NonNull default Specification<T> or(@Nullable Specification<T> other)
ORs the given specification to the current one.- Parameters:
other- can be null.- Returns:
- The disjunction of the specifications
-
toPredicate
@Nullable javax.persistence.criteria.Predicate toPredicate(@NonNull javax.persistence.criteria.Root<T> root, @NonNull javax.persistence.criteria.CriteriaQuery<?> query, @NonNull javax.persistence.criteria.CriteriaBuilder criteriaBuilder)Creates a WHERE clause for a query of the referenced entity in form of aPredicatefor the givenRootandCriteriaQuery.- Parameters:
root- must not be null.query- must not be null.criteriaBuilder- must not be null.- Returns:
- a
Predicate, may be null.
-
-