public final class ExpressionUtils extends Object
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.Modifier and Type | Method and Description |
---|---|
static <T> Expression<T> |
all(CollectionExpression<?,? super T> col)
Create a
all col expression |
static <T> Expression<T> |
all(SubQueryExpression<? extends T> col)
Create a
all col expression |
static Predicate |
allOf(Collection<Predicate> exprs)
Create the intersection of the given arguments
|
static Predicate |
allOf(Predicate... exprs)
Create the intersection of the given arguments
|
static Predicate |
and(Predicate left,
Predicate right)
Create the intersection of the given arguments
|
static <T> Expression<T> |
any(CollectionExpression<?,? super T> col)
Create a
any col expression |
static <T> Expression<T> |
any(SubQueryExpression<? extends T> col)
Create a
any col expression |
static Predicate |
anyOf(Collection<Predicate> exprs)
Create the union of the given arguments
|
static Predicate |
anyOf(Predicate... exprs)
Create the union of the given arguments
|
static <D> Expression<D> |
as(Expression<D> source,
Path<D> alias)
Create an alias expression with the given source and alias
|
static <D> Expression<D> |
as(Expression<D> source,
String alias)
Create an alias expression with the given source and alias
|
static Expression<Long> |
count(Expression<?> source)
Create a
count(source) expression |
static String |
createRootVariable(Path<?> path)
Create a new root variable based on the given path
|
static String |
createRootVariable(Path<?> path,
int suffix)
Create a new root variable based on the given path and suffix
|
static com.google.common.collect.ImmutableList<Expression<?>> |
distinctList(Expression<?>... args)
Create a distinct list of the given args
|
static com.google.common.collect.ImmutableList<Expression<?>> |
distinctList(Expression<?>[]... args)
Create a distinct list of the concatenated array contents
|
static <D> Predicate |
eq(Expression<D> left,
Expression<? extends D> right)
Create a
left == right expression |
static <D> Predicate |
eqConst(Expression<D> left,
D constant)
Create a
left == constant expression |
static <T> Expression<T> |
extract(Expression<T> expr)
Get the potentially wrapped expression
|
static <D> Predicate |
in(Expression<D> left,
Collection<? extends D> right)
Create a
left in right expression |
static <D> Predicate |
in(Expression<D> left,
CollectionExpression<?,? extends D> right)
Create a
left in right expression |
static <D> Predicate |
in(Expression<D> left,
SubQueryExpression<? extends D> right)
Create a
left in right expression |
static <D> Predicate |
inAny(Expression<D> left,
Iterable<? extends Collection<? extends D>> lists)
Create a
left in right or... expression for each list |
static Predicate |
isNotNull(Expression<?> left)
Create a
left is not null expression |
static Predicate |
isNull(Expression<?> left)
Create a
left is null expression |
static Expression<String> |
likeToRegex(Expression<String> expr)
Convert the given like pattern to a regex pattern
|
static Expression<String> |
likeToRegex(Expression<String> expr,
boolean matchStartAndEnd)
Convert the given like pattern to a regex pattern
|
static <T> Expression<T> |
list(Class<T> clazz,
Expression<?>... exprs)
Create a list expression for the given arguments
|
static <T> Expression<T> |
list(Class<T> clazz,
List<? extends Expression<?>> exprs)
Create a list expression for the given arguments
|
static <D> Predicate |
ne(Expression<D> left,
Expression<? super D> right)
Create a
left != right expression |
static <D> Predicate |
neConst(Expression<D> left,
D constant)
Create a
left != constant expression |
static <D> Predicate |
notIn(Expression<D> left,
Collection<? extends D> right)
Create a
left not in right expression |
static <D> Predicate |
notIn(Expression<D> left,
CollectionExpression<?,? extends D> right)
Create a
left not in right expression |
static <D> Predicate |
notIn(Expression<D> left,
SubQueryExpression<? extends D> right)
Create a
left not in right expression |
static <D> Predicate |
notInAny(Expression<D> left,
Iterable<? extends Collection<? extends D>> lists)
Create a
left not in right and... expression for each list |
static <T> Operation<T> |
operation(Class<? extends T> type,
Operator operator,
Expression<?>... args)
Create a new Operation expression
|
static <T> Operation<T> |
operation(Class<? extends T> type,
Operator operator,
com.google.common.collect.ImmutableList<Expression<?>> args)
Create a new Operation expression
|
static Predicate |
or(Predicate left,
Predicate right)
Create a
left or right expression |
static Expression<?> |
orderBy(List<OrderSpecifier<?>> args)
Create an expression out of the given order specifiers
|
static <T> Path<T> |
path(Class<? extends T> type,
Path<?> parent,
String property)
Create a new Path expression
|
static <T> Path<T> |
path(Class<? extends T> type,
PathMetadata metadata)
Create a new Path expression
|
static <T> Path<T> |
path(Class<? extends T> type,
String variable)
Create a new Path expression
|
static PredicateOperation |
predicate(Operator operator,
Expression<?>... args)
Create a new Operation expression
|
static PredicateOperation |
predicate(Operator operator,
com.google.common.collect.ImmutableList<Expression<?>> args)
Create a new Operation expression
|
static PredicateTemplate |
predicateTemplate(String template,
com.google.common.collect.ImmutableList<?> args)
Deprecated.
Use
predicateTemplate(String, List) instead. |
static PredicateTemplate |
predicateTemplate(String template,
List<?> args)
Create a new Template expression
|
static PredicateTemplate |
predicateTemplate(String template,
Object... args)
Create a new Template expression
|
static PredicateTemplate |
predicateTemplate(Template template,
com.google.common.collect.ImmutableList<?> args)
Deprecated.
Use
predicateTemplate(Template, List) instead. |
static PredicateTemplate |
predicateTemplate(Template template,
List<?> args)
Create a new Template expression
|
static PredicateTemplate |
predicateTemplate(Template template,
Object... args)
Create a new Template expression
|
static Expression<String> |
regexToLike(Expression<String> expr)
Convert the given expression from regex form to like
|
static <T> TemplateExpression<T> |
template(Class<? extends T> cl,
String template,
com.google.common.collect.ImmutableList<?> args)
Deprecated.
Use
template(Class, String, List) instead. |
static <T> TemplateExpression<T> |
template(Class<? extends T> cl,
String template,
List<?> args)
Create a new Template expression
|
static <T> TemplateExpression<T> |
template(Class<? extends T> cl,
String template,
Object... args)
Create a new Template expression
|
static <T> TemplateExpression<T> |
template(Class<? extends T> cl,
Template template,
com.google.common.collect.ImmutableList<?> args)
Deprecated.
Use
template(Class, Template, List) instead. |
static <T> TemplateExpression<T> |
template(Class<? extends T> cl,
Template template,
List<?> args)
Create a new Template expression
|
static <T> TemplateExpression<T> |
template(Class<? extends T> cl,
Template template,
Object... args)
Create a new Template expression
|
static Expression<?> |
toExpression(Object o)
Converts the given object to an Expression
|
static Expression<String> |
toLower(Expression<String> stringExpression)
Converts the given expression to lower(expression)
|
public static <T> Operation<T> operation(Class<? extends T> type, Operator operator, Expression<?>... args)
type
- type of expressionoperator
- operatorargs
- operation argumentspublic static <T> Operation<T> operation(Class<? extends T> type, Operator operator, com.google.common.collect.ImmutableList<Expression<?>> args)
type
- type of expressionoperator
- operatorargs
- operation argumentspublic static PredicateOperation predicate(Operator operator, Expression<?>... args)
operator
- operatorargs
- operation argumentspublic static PredicateOperation predicate(Operator operator, com.google.common.collect.ImmutableList<Expression<?>> args)
operator
- operatorargs
- operation argumentspublic static <T> Path<T> path(Class<? extends T> type, String variable)
type
- type of expressionvariable
- variable namepublic static <T> Path<T> path(Class<? extends T> type, Path<?> parent, String property)
type
- type of expressionparent
- parent pathproperty
- property namepublic static <T> Path<T> path(Class<? extends T> type, PathMetadata metadata)
T
- type of expressiontype
- type of expressionmetadata
- path metadatapublic static PredicateTemplate predicateTemplate(String template, Object... args)
template
- templateargs
- template parameters@Deprecated public static PredicateTemplate predicateTemplate(String template, com.google.common.collect.ImmutableList<?> args)
predicateTemplate(String, List)
instead.template
- templateargs
- template parameterspublic static PredicateTemplate predicateTemplate(String template, List<?> args)
template
- templateargs
- template parameterspublic static PredicateTemplate predicateTemplate(Template template, Object... args)
template
- templateargs
- template parameters@Deprecated public static PredicateTemplate predicateTemplate(Template template, com.google.common.collect.ImmutableList<?> args)
predicateTemplate(Template, List)
instead.template
- templateargs
- template parameterspublic static PredicateTemplate predicateTemplate(Template template, List<?> args)
template
- templateargs
- template parameterspublic static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, Object... args)
cl
- type of expressiontemplate
- templateargs
- template parameters@Deprecated public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, com.google.common.collect.ImmutableList<?> args)
template(Class, String, List)
instead.cl
- type of expressiontemplate
- templateargs
- template parameterspublic static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, List<?> args)
cl
- type of expressiontemplate
- templateargs
- template parameterspublic static <T> TemplateExpression<T> template(Class<? extends T> cl, Template template, Object... args)
cl
- type of expressiontemplate
- templateargs
- template parameters@Deprecated public static <T> TemplateExpression<T> template(Class<? extends T> cl, Template template, com.google.common.collect.ImmutableList<?> args)
template(Class, Template, List)
instead.cl
- type of expressiontemplate
- templateargs
- template parameterspublic static <T> TemplateExpression<T> template(Class<? extends T> cl, Template template, List<?> args)
cl
- type of expressiontemplate
- templateargs
- template parameterspublic static <T> Expression<T> all(CollectionExpression<?,? super T> col)
all col
expressioncol
- collection expressionpublic static <T> Expression<T> any(CollectionExpression<?,? super T> col)
any col
expressioncol
- collection expressionpublic static <T> Expression<T> all(SubQueryExpression<? extends T> col)
all col
expressioncol
- subquery expressionpublic static <T> Expression<T> any(SubQueryExpression<? extends T> col)
any col
expressioncol
- subquery expression@Nullable public static Predicate allOf(Collection<Predicate> exprs)
exprs
- predicates@Nullable public static Predicate allOf(Predicate... exprs)
exprs
- predicatespublic static Predicate and(Predicate left, Predicate right)
left
- lhs of expressionright
- rhs of expression@Nullable public static Predicate anyOf(Collection<Predicate> exprs)
exprs
- predicate@Nullable public static Predicate anyOf(Predicate... exprs)
exprs
- predicatespublic static <D> Expression<D> as(Expression<D> source, Path<D> alias)
D
- type of expressionsource
- sourcealias
- aliaspublic static <D> Expression<D> as(Expression<D> source, String alias)
D
- type of expressionsource
- sourcealias
- aliaspublic static Expression<Long> count(Expression<?> source)
count(source)
expressionsource
- sourcepublic static <D> Predicate eqConst(Expression<D> left, D constant)
left == constant
expressionD
- type of expressionsleft
- lhs of expressionconstant
- rhs of expressionpublic static <D> Predicate eq(Expression<D> left, Expression<? extends D> right)
left == right
expressionD
- type of expressionsleft
- lhs of expressionright
- rhs of expressionpublic static <D> Predicate in(Expression<D> left, CollectionExpression<?,? extends D> right)
left in right
expressionD
- type of expressionsleft
- lhs of expressionright
- rhs of expressionpublic static <D> Predicate in(Expression<D> left, SubQueryExpression<? extends D> right)
left in right
expressionD
- type of expressionsleft
- lhs of expressionright
- rhs of expressionpublic static <D> Predicate in(Expression<D> left, Collection<? extends D> right)
left in right
expressionD
- element typeleft
- lhs of expressionright
- rhs of expressionpublic static <D> Predicate inAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists)
left in right or...
expression for each listD
- element typeleft
- lists
- left in right or...
expressionpublic static Predicate isNull(Expression<?> left)
left is null
expressionleft
- operation argumentpublic static Predicate isNotNull(Expression<?> left)
left is not null
expressionleft
- operation argumentpublic static Expression<String> likeToRegex(Expression<String> expr)
expr
- expression to convertpublic static Expression<String> likeToRegex(Expression<String> expr, boolean matchStartAndEnd)
expr
- expression to be convertedmatchStartAndEnd
- if start and end should be matched as wellpublic static <T> Expression<T> list(Class<T> clazz, Expression<?>... exprs)
exprs
- list elementspublic static <T> Expression<T> list(Class<T> clazz, List<? extends Expression<?>> exprs)
exprs
- list elementspublic static Expression<String> regexToLike(Expression<String> expr)
expr
- expression to convertpublic static <D> Predicate neConst(Expression<D> left, D constant)
left != constant
expressionD
- type of expressionleft
- lhs of expressionconstant
- rhs of expressionpublic static <D> Predicate ne(Expression<D> left, Expression<? super D> right)
left != right
expressionD
- type of expressionsleft
- lhs of expressionright
- rhs of expressionpublic static <D> Predicate notIn(Expression<D> left, CollectionExpression<?,? extends D> right)
left not in right
expressionD
- type of expressionsleft
- lhs of expressionright
- rhs of expressionpublic static <D> Predicate notIn(Expression<D> left, SubQueryExpression<? extends D> right)
left not in right
expressionD
- type of expressionsleft
- lhs of expressionright
- rhs of expressionpublic static <D> Predicate notIn(Expression<D> left, Collection<? extends D> right)
left not in right
expressionD
- type of expressionsleft
- lhs of expressionright
- rhs of expressionpublic static <D> Predicate notInAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists)
left not in right and...
expression for each listD
- left
- lists
- left not in right and...
expressionpublic static Predicate or(Predicate left, Predicate right)
left or right
expressionleft
- lhs of expressionright
- rhs of expressionpublic static com.google.common.collect.ImmutableList<Expression<?>> distinctList(Expression<?>... args)
args
- elementspublic static com.google.common.collect.ImmutableList<Expression<?>> distinctList(Expression<?>[]... args)
args
- elementspublic static <T> Expression<T> extract(Expression<T> expr)
expr
- expression to analyzepublic static String createRootVariable(Path<?> path, int suffix)
path
- base pathsuffix
- suffix for variable namepublic static String createRootVariable(Path<?> path)
path
- base pathpublic static Expression<?> toExpression(Object o)
Casts expressions and wraps everything else into co
o
- object to convertpublic static Expression<String> toLower(Expression<String> stringExpression)
Constants are lower()ed at creation time
stringExpression
- the string to lower()public static Expression<?> orderBy(List<OrderSpecifier<?>> args)
args
- orderCopyright © 2007–2016 Querydsl. All rights reserved.