- All Known Implementing Classes:
NumericQueryCriteria,SimpleQueryCriteria,StringQueryCriteria,ValueBetween,ValueContaining,ValueEndsWith,ValueGreaterThan,ValueGreaterThanOrEqualTo,ValueIs,ValueIsOneOf,ValueLessThan,ValueLessThanOrEqualTo,ValueLike,ValueStartsWith
public interface QueryCriteria
Used to provide criteria for database querying. Comes with static utility methods for easily creating these using semantic method chaining. Example:
import static io.john.amiscaray.quak.data.query.QueryCriteria.*;
public class Test {
public void test() {
QueryCriteria criteria = valueOfField("name", contains("oh"));
}
}-
Method Summary
Modifier and TypeMethodDescriptiondefault QueryCriteriaand(QueryCriteria queryCriteria) ANDs this query with another one.static QueryCriteriaProviderCreates a query criteria provider testing that the value of a field contains a substring.static QueryCriteriaProviderCreates a query criteria provider testing that the value of a field ends with a suffix.jakarta.persistence.criteria.PredicategetTestPredicate(jakarta.persistence.criteria.Root<?> queryRoot, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) Creates a predicate using the given query root and criteria builder.static QueryCriteriaProviderCreates a query criteria provider testing that the value of a field equals to the given value.static QueryCriteriaProviderCreates a query criteria provider testing that the value of a field is between a min and a max (inclusive).static QueryCriteriaProviderisGreaterThan(Number value) Creates a query criteria provider testing that the value of a field is greater than some value.static QueryCriteriaProviderisGreaterThanOrEqualTo(Number value) Creates a query criteria provider testing that the value of a field is greater than or equal to some value.static QueryCriteriaProviderisLessThan(Number value) Creates a query criteria provider testing that the value of a field is less than some value.static QueryCriteriaProviderisLessThanOrEqualTo(Number value) Creates a query criteria provider testing that the value of a field is less than or equal to some value.static QueryCriteriaProviderCreates a query criteria provider testing that the value of a field matches some regex (using SQL syntax).static QueryCriteriaProviderCreates a query criteria provider testing that the value of a field equals one of the given values.static QueryCriteriaProvidermatchesAllOf(QueryCriteriaProvider... queryCriteriaProviders) ANDs the given query criteria providers into a single query criteria provider.default QueryCriteriaor(QueryCriteria queryCriteria) ORs this query with another one.static QueryCriteriaProviderstartsWith(String prefix) Creates a query criteria provider testing that the value of a field starts with a prefix.static QueryCriteriavalueOfField(String fieldName, QueryCriteriaProvider queryCriteriaProvider) Creates a query criteria testing that the value of a field matches some condition provided by a query criteria provider.
-
Method Details
-
getTestPredicate
jakarta.persistence.criteria.Predicate getTestPredicate(jakarta.persistence.criteria.Root<?> queryRoot, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) Creates a predicate using the given query root and criteria builder.- Parameters:
queryRoot- The query root.criteriaBuilder- The criteria builder.- Returns:
- The predicate representing the criteria to query the database.
-
and
ANDs this query with another one.- Parameters:
queryCriteria- The other query.- Returns:
- The criteria ANDed with the other criteria
-
or
ORs this query with another one.- Parameters:
queryCriteria- The other query.- Returns:
- A new QueryCriteria representing the criteria ORed with the other criteria
-
valueOfField
Creates a query criteria testing that the value of a field matches some condition provided by a query criteria provider.- Parameters:
fieldName- The name of the field.queryCriteriaProvider- A query criteria provider. This should take the name of the field and test something on it.- Returns:
- The query about the value of the given field.
-
matchesAllOf
ANDs the given query criteria providers into a single query criteria provider.- Parameters:
queryCriteriaProviders- The query criteria providers.- Returns:
- The query criteria providers conjoined into a single one.
-
is
Creates a query criteria provider testing that the value of a field equals to the given value.- Parameters:
value- The value.- Returns:
- A query criteria provider.
-
isOneOf
Creates a query criteria provider testing that the value of a field equals one of the given values.- Parameters:
values- The values.- Returns:
- A query criteria provider.
-
isBetween
Creates a query criteria provider testing that the value of a field is between a min and a max (inclusive).- Parameters:
min- The min.max- The max.- Returns:
- A query criteria provider.
-
isGreaterThan
Creates a query criteria provider testing that the value of a field is greater than some value.- Parameters:
value- The value.- Returns:
- A query criteria provider.
-
isGreaterThanOrEqualTo
Creates a query criteria provider testing that the value of a field is greater than or equal to some value.- Parameters:
value- The value.- Returns:
- A query criteria provider.
-
isLessThan
Creates a query criteria provider testing that the value of a field is less than some value.- Parameters:
value- The value.- Returns:
- A query criteria provider.
-
isLessThanOrEqualTo
Creates a query criteria provider testing that the value of a field is less than or equal to some value.- Parameters:
value- The value.- Returns:
- A query criteria provider.
-
contains
Creates a query criteria provider testing that the value of a field contains a substring.- Parameters:
substring- The substring.- Returns:
- A query criteria provider.
-
endsWith
Creates a query criteria provider testing that the value of a field ends with a suffix.- Parameters:
suffix- The suffix.- Returns:
- A query criteria provider.
-
startsWith
Creates a query criteria provider testing that the value of a field starts with a prefix.- Parameters:
prefix- The prefix- Returns:
- A query criteria provider.
-
isLike
Creates a query criteria provider testing that the value of a field matches some regex (using SQL syntax).- Parameters:
regex- The regex.- Returns:
- A query criteria provider.
-