Package com.querydsl.core.types
Class ExpressionUtils
java.lang.Object
com.querydsl.core.types.ExpressionUtils
ExpressionUtils provides utilities for constructing common operation instances. This class is
used internally in Querydsl and is not suitable to be used in cases where DSL methods are needed,
since the Expression implementations used in this class are minimal internal implementations.- Author:
- tiwe
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Expression<T>all(CollectionExpression<?, ? super T> col) Create aall colexpressionstatic <T> Expression<T>all(SubQueryExpression<? extends T> col) Create aall colexpressionstatic @Nullable PredicateCreate the intersection of the given argumentsstatic @Nullable PredicateallOf(Collection<Predicate> exprs) Create the intersection of the given argumentsstatic PredicateCreate the intersection of the given argumentsstatic <T> Expression<T>any(CollectionExpression<?, ? super T> col) Create aany colexpressionstatic <T> Expression<T>any(SubQueryExpression<? extends T> col) Create aany colexpressionstatic @Nullable PredicateCreate the union of the given argumentsstatic @Nullable PredicateanyOf(Collection<Predicate> exprs) Create the union of the given argumentsstatic <D> Expression<D>as(Expression<D> source, Path<D> alias) Create an alias expression with the given source and aliasstatic <D> Expression<D>as(Expression<D> source, String alias) Create an alias expression with the given source and aliasstatic Expression<Long>count(Expression<?> source) Create acount(source)expressionstatic StringcreateRootVariable(Path<?> path) Create a new root variable based on the given pathstatic StringcreateRootVariable(Path<?> path, int suffix) Create a new root variable based on the given path and suffixstatic List<Expression<?>>distinctList(Expression<?>... args) Create a distinct list of the given argsstatic List<Expression<?>>distinctList(Expression<?>[]... args) Create a distinct list of the concatenated array contentsstatic <D> Predicateeq(Expression<D> left, Expression<? extends D> right) Create aleft == rightexpressionstatic <D> PredicateeqConst(Expression<D> left, D constant) Create aleft == constantexpressionstatic <T> Expression<T>extract(Expression<T> expr) Get the potentially wrapped expressionstatic <D> Predicatein(Expression<D> left, CollectionExpression<?, ? extends D> right) Create aleft in rightexpressionstatic <D> Predicatein(Expression<D> left, SubQueryExpression<? extends D> right) Create aleft in rightexpressionstatic <D> Predicatein(Expression<D> left, Collection<? extends D> right) Create aleft in rightexpressionstatic <D> PredicateinAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists) Create aleft in right or...expression for each liststatic PredicateisNotNull(Expression<?> left) Create aleft is not nullexpressionstatic PredicateisNull(Expression<?> left) Create aleft is nullexpressionstatic Expression<String>likeToRegex(Expression<String> expr) Convert the given like pattern to a regex patternstatic Expression<String>likeToRegex(Expression<String> expr, boolean matchStartAndEnd) Convert the given like pattern to a regex patternstatic <T> Expression<T>list(Class<T> clazz, Expression<?>... exprs) Create a list expression for the given argumentsstatic <T> Expression<T>list(Class<T> clazz, List<? extends Expression<?>> exprs) Create a list expression for the given argumentsstatic <D> Predicatene(Expression<D> left, Expression<? super D> right) Create aleft != rightexpressionstatic <D> PredicateneConst(Expression<D> left, D constant) Create aleft != constantexpressionstatic <D> PredicatenotIn(Expression<D> left, CollectionExpression<?, ? extends D> right) Create aleft not in rightexpressionstatic <D> PredicatenotIn(Expression<D> left, SubQueryExpression<? extends D> right) Create aleft not in rightexpressionstatic <D> PredicatenotIn(Expression<D> left, Collection<? extends D> right) Create aleft not in rightexpressionstatic <D> PredicatenotInAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists) Create aleft not in right and...expression for each liststatic <T> Operation<T>operation(Class<? extends T> type, Operator operator, Expression<?>... args) Create a new Operation expressionstatic <T> Operation<T>operation(Class<? extends T> type, Operator operator, List<Expression<?>> args) Create a new Operation expressionstatic PredicateCreate aleft or rightexpressionstatic Expression<?>orderBy(List<OrderSpecifier<?>> args) Create an expression out of the given order specifiersstatic <T> Path<T>Create a new Path expressionstatic <T> Path<T>path(Class<? extends T> type, PathMetadata metadata) Create a new Path expressionstatic <T> Path<T>Create a new Path expressionstatic PredicateOperationpredicate(Operator operator, Expression<?>... args) Create a new Operation expressionstatic PredicateOperationpredicate(Operator operator, List<Expression<?>> args) Create a new Operation expressionstatic PredicateTemplatepredicateTemplate(Template template, Object... args) Create a new Template expressionstatic PredicateTemplatepredicateTemplate(Template template, List<?> args) Create a new Template expressionstatic PredicateTemplatepredicateTemplate(String template, Object... args) Create a new Template expressionstatic PredicateTemplatepredicateTemplate(String template, List<?> args) Create a new Template expressionstatic Expression<String>regexToLike(Expression<String> expr) Convert the given expression from regex form to likestatic <T> TemplateExpression<T>Create a new Template expressionstatic <T> TemplateExpression<T>Create a new Template expressionstatic <T> TemplateExpression<T>Create a new Template expressionstatic <T> TemplateExpression<T>Create a new Template expressionstatic Expression<?>Converts the given object to an Expressionstatic Expression<String>toLower(Expression<String> stringExpression) Converts the given expression to lower(expression)
-
Method Details
-
operation
public static <T> Operation<T> operation(Class<? extends T> type, Operator operator, Expression<?>... args) Create a new Operation expression- Parameters:
type- type of expressionoperator- operatorargs- operation arguments- Returns:
- operation expression
-
operation
public static <T> Operation<T> operation(Class<? extends T> type, Operator operator, List<Expression<?>> args) Create a new Operation expression- Parameters:
type- type of expressionoperator- operatorargs- operation arguments- Returns:
- operation expression
-
predicate
Create a new Operation expression- Parameters:
operator- operatorargs- operation arguments- Returns:
- operation expression
-
predicate
Create a new Operation expression- Parameters:
operator- operatorargs- operation arguments- Returns:
- operation expression
-
path
Create a new Path expression- Parameters:
type- type of expressionvariable- variable name- Returns:
- path expression
-
path
Create a new Path expression- Parameters:
type- type of expressionparent- parent pathproperty- property name- Returns:
- property path
-
path
Create a new Path expression- Type Parameters:
T- type of expression- Parameters:
type- type of expressionmetadata- path metadata- Returns:
- path expression
-
predicateTemplate
Create a new Template expression- Parameters:
template- templateargs- template parameters- Returns:
- template expression
-
predicateTemplate
Create a new Template expression- Parameters:
template- templateargs- template parameters- Returns:
- template expression
-
predicateTemplate
Create a new Template expression- Parameters:
template- templateargs- template parameters- Returns:
- template expression
-
predicateTemplate
Create a new Template expression- Parameters:
template- templateargs- template parameters- Returns:
- template expression
-
template
public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, Object... args) Create a new Template expression- Parameters:
cl- type of expressiontemplate- templateargs- template parameters- Returns:
- template expression
-
template
public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, List<?> args) Create a new Template expression- Parameters:
cl- type of expressiontemplate- templateargs- template parameters- Returns:
- template expression
-
template
public static <T> TemplateExpression<T> template(Class<? extends T> cl, Template template, Object... args) Create a new Template expression- Parameters:
cl- type of expressiontemplate- templateargs- template parameters- Returns:
- template expression
-
template
public static <T> TemplateExpression<T> template(Class<? extends T> cl, Template template, List<?> args) Create a new Template expression- Parameters:
cl- type of expressiontemplate- templateargs- template parameters- Returns:
- template expression
-
all
Create aall colexpression- Parameters:
col- collection expression- Returns:
- all col
-
any
Create aany colexpression- Parameters:
col- collection expression- Returns:
- any col
-
all
Create aall colexpression- Parameters:
col- subquery expression- Returns:
- all col
-
any
Create aany colexpression- Parameters:
col- subquery expression- Returns:
- any col
-
allOf
Create the intersection of the given arguments- Parameters:
exprs- predicates- Returns:
- intersection
-
allOf
Create the intersection of the given arguments- Parameters:
exprs- predicates- Returns:
- intersection
-
and
Create the intersection of the given arguments- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left and right
-
anyOf
Create the union of the given arguments- Parameters:
exprs- predicate- Returns:
- union
-
anyOf
Create the union of the given arguments- Parameters:
exprs- predicates- Returns:
- union
-
as
Create an alias expression with the given source and alias- Type Parameters:
D- type of expression- Parameters:
source- sourcealias- alias- Returns:
- source as alias
-
as
Create an alias expression with the given source and alias- Type Parameters:
D- type of expression- Parameters:
source- sourcealias- alias- Returns:
- source as alias
-
count
Create acount(source)expression- Parameters:
source- source- Returns:
- count(source)
-
eqConst
Create aleft == constantexpression- Type Parameters:
D- type of expressions- Parameters:
left- lhs of expressionconstant- rhs of expression- Returns:
- left == constant
-
eq
Create aleft == rightexpression- Type Parameters:
D- type of expressions- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left == right
-
in
Create aleft in rightexpression- Type Parameters:
D- type of expressions- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left in right
-
in
Create aleft in rightexpression- Type Parameters:
D- type of expressions- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left in right
-
in
Create aleft in rightexpression- Type Parameters:
D- element type- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left in right
-
inAny
public static <D> Predicate inAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists) Create aleft in right or...expression for each list- Type Parameters:
D- element type- Parameters:
left-lists-- Returns:
- a
left in right or...expression
-
isNull
Create aleft is nullexpression- Parameters:
left- operation argument- Returns:
- left is null
-
isNotNull
Create aleft is not nullexpression- Parameters:
left- operation argument- Returns:
- left is null
-
likeToRegex
Convert the given like pattern to a regex pattern- Parameters:
expr- expression to convert- Returns:
- converted expression
-
likeToRegex
Convert the given like pattern to a regex pattern- Parameters:
expr- expression to be convertedmatchStartAndEnd- if start and end should be matched as well- Returns:
- converted expression
-
list
Create a list expression for the given arguments- Parameters:
exprs- list elements- Returns:
- list expression
-
list
Create a list expression for the given arguments- Parameters:
exprs- list elements- Returns:
- list expression
-
regexToLike
Convert the given expression from regex form to like- Parameters:
expr- expression to convert- Returns:
- converted expression
-
neConst
Create aleft != constantexpression- Type Parameters:
D- type of expression- Parameters:
left- lhs of expressionconstant- rhs of expression- Returns:
- left != constant
-
ne
Create aleft != rightexpression- Type Parameters:
D- type of expressions- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left != right
-
notIn
Create aleft not in rightexpression- Type Parameters:
D- type of expressions- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left not in right
-
notIn
Create aleft not in rightexpression- Type Parameters:
D- type of expressions- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left not in right
-
notIn
Create aleft not in rightexpression- Type Parameters:
D- type of expressions- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left not in right
-
notInAny
public static <D> Predicate notInAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists) Create aleft not in right and...expression for each list- Type Parameters:
D-- Parameters:
left-lists-- Returns:
- a
left not in right and...expression
-
or
Create aleft or rightexpression- Parameters:
left- lhs of expressionright- rhs of expression- Returns:
- left or right
-
distinctList
Create a distinct list of the given args- Parameters:
args- elements- Returns:
- list with distinct elements
-
distinctList
Create a distinct list of the concatenated array contents- Parameters:
args- elements- Returns:
- list with distinct elements
-
extract
Get the potentially wrapped expression- Parameters:
expr- expression to analyze- Returns:
- inner expression
-
createRootVariable
Create a new root variable based on the given path and suffix- Parameters:
path- base pathsuffix- suffix for variable name- Returns:
- path expression
-
createRootVariable
Create a new root variable based on the given path- Parameters:
path- base path- Returns:
- variable name
-
toExpression
Converts the given object to an ExpressionCasts expressions and wraps everything else into co
- Parameters:
o- object to convert- Returns:
- converted argument
-
toLower
Converts the given expression to lower(expression)Constants are lower()ed at creation time
- Parameters:
stringExpression- the string to lower()- Returns:
- lower(stringExpression)
-
orderBy
Create an expression out of the given order specifiers- Parameters:
args- order- Returns:
- expression for order
-