Class ExpressionUtils

java.lang.Object
com.querydsl.core.types.ExpressionUtils

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.
Author:
tiwe
  • 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 expression
      operator - operator
      args - 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 expression
      operator - operator
      args - operation arguments
      Returns:
      operation expression
    • predicate

      public static PredicateOperation predicate(Operator operator, Expression<?>... args)
      Create a new Operation expression
      Parameters:
      operator - operator
      args - operation arguments
      Returns:
      operation expression
    • predicate

      public static PredicateOperation predicate(Operator operator, List<Expression<?>> args)
      Create a new Operation expression
      Parameters:
      operator - operator
      args - operation arguments
      Returns:
      operation expression
    • path

      public static <T> Path<T> path(Class<? extends T> type, String variable)
      Create a new Path expression
      Parameters:
      type - type of expression
      variable - variable name
      Returns:
      path expression
    • path

      public static <T> Path<T> path(Class<? extends T> type, Path<?> parent, String property)
      Create a new Path expression
      Parameters:
      type - type of expression
      parent - parent path
      property - property name
      Returns:
      property path
    • path

      public static <T> Path<T> path(Class<? extends T> type, PathMetadata metadata)
      Create a new Path expression
      Type Parameters:
      T - type of expression
      Parameters:
      type - type of expression
      metadata - path metadata
      Returns:
      path expression
    • predicateTemplate

      public static PredicateTemplate predicateTemplate(String template, Object... args)
      Create a new Template expression
      Parameters:
      template - template
      args - template parameters
      Returns:
      template expression
    • predicateTemplate

      public static PredicateTemplate predicateTemplate(String template, List<?> args)
      Create a new Template expression
      Parameters:
      template - template
      args - template parameters
      Returns:
      template expression
    • predicateTemplate

      public static PredicateTemplate predicateTemplate(Template template, Object... args)
      Create a new Template expression
      Parameters:
      template - template
      args - template parameters
      Returns:
      template expression
    • predicateTemplate

      public static PredicateTemplate predicateTemplate(Template template, List<?> args)
      Create a new Template expression
      Parameters:
      template - template
      args - 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 expression
      template - template
      args - 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 expression
      template - template
      args - 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 expression
      template - template
      args - 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 expression
      template - template
      args - template parameters
      Returns:
      template expression
    • all

      public static <T> Expression<T> all(CollectionExpression<?,? super T> col)
      Create a all col expression
      Parameters:
      col - collection expression
      Returns:
      all col
    • any

      public static <T> Expression<T> any(CollectionExpression<?,? super T> col)
      Create a any col expression
      Parameters:
      col - collection expression
      Returns:
      any col
    • all

      public static <T> Expression<T> all(SubQueryExpression<? extends T> col)
      Create a all col expression
      Parameters:
      col - subquery expression
      Returns:
      all col
    • any

      public static <T> Expression<T> any(SubQueryExpression<? extends T> col)
      Create a any col expression
      Parameters:
      col - subquery expression
      Returns:
      any col
    • allOf

      @Nullable public static @Nullable Predicate allOf(Collection<Predicate> exprs)
      Create the intersection of the given arguments
      Parameters:
      exprs - predicates
      Returns:
      intersection
    • allOf

      @Nullable public static @Nullable Predicate allOf(Predicate... exprs)
      Create the intersection of the given arguments
      Parameters:
      exprs - predicates
      Returns:
      intersection
    • and

      public static Predicate and(Predicate left, Predicate right)
      Create the intersection of the given arguments
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left and right
    • anyOf

      @Nullable public static @Nullable Predicate anyOf(Collection<Predicate> exprs)
      Create the union of the given arguments
      Parameters:
      exprs - predicate
      Returns:
      union
    • anyOf

      @Nullable public static @Nullable Predicate anyOf(Predicate... exprs)
      Create the union of the given arguments
      Parameters:
      exprs - predicates
      Returns:
      union
    • as

      public static <D> Expression<D> as(Expression<D> source, Path<D> alias)
      Create an alias expression with the given source and alias
      Type Parameters:
      D - type of expression
      Parameters:
      source - source
      alias - alias
      Returns:
      source as alias
    • as

      public static <D> Expression<D> as(Expression<D> source, String alias)
      Create an alias expression with the given source and alias
      Type Parameters:
      D - type of expression
      Parameters:
      source - source
      alias - alias
      Returns:
      source as alias
    • count

      public static Expression<Long> count(Expression<?> source)
      Create a count(source) expression
      Parameters:
      source - source
      Returns:
      count(source)
    • eqConst

      public static <D> Predicate eqConst(Expression<D> left, D constant)
      Create a left == constant expression
      Type Parameters:
      D - type of expressions
      Parameters:
      left - lhs of expression
      constant - rhs of expression
      Returns:
      left == constant
    • eq

      public static <D> Predicate eq(Expression<D> left, Expression<? extends D> right)
      Create a left == right expression
      Type Parameters:
      D - type of expressions
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left == right
    • in

      public static <D> Predicate in(Expression<D> left, CollectionExpression<?,? extends D> right)
      Create a left in right expression
      Type Parameters:
      D - type of expressions
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left in right
    • in

      public static <D> Predicate in(Expression<D> left, SubQueryExpression<? extends D> right)
      Create a left in right expression
      Type Parameters:
      D - type of expressions
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left in right
    • in

      public static <D> Predicate in(Expression<D> left, Collection<? extends D> right)
      Create a left in right expression
      Type Parameters:
      D - element type
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left in right
    • inAny

      public static <D> Predicate inAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists)
      Create a left in right or... expression for each list
      Type Parameters:
      D - element type
      Parameters:
      left -
      lists -
      Returns:
      a left in right or... expression
    • isNull

      public static Predicate isNull(Expression<?> left)
      Create a left is null expression
      Parameters:
      left - operation argument
      Returns:
      left is null
    • isNotNull

      public static Predicate isNotNull(Expression<?> left)
      Create a left is not null expression
      Parameters:
      left - operation argument
      Returns:
      left is null
    • likeToRegex

      public static Expression<String> likeToRegex(Expression<String> expr)
      Convert the given like pattern to a regex pattern
      Parameters:
      expr - expression to convert
      Returns:
      converted expression
    • likeToRegex

      public static Expression<String> likeToRegex(Expression<String> expr, boolean matchStartAndEnd)
      Convert the given like pattern to a regex pattern
      Parameters:
      expr - expression to be converted
      matchStartAndEnd - if start and end should be matched as well
      Returns:
      converted expression
    • list

      public static <T> Expression<T> list(Class<T> clazz, Expression<?>... exprs)
      Create a list expression for the given arguments
      Parameters:
      exprs - list elements
      Returns:
      list expression
    • list

      public static <T> Expression<T> list(Class<T> clazz, List<? extends Expression<?>> exprs)
      Create a list expression for the given arguments
      Parameters:
      exprs - list elements
      Returns:
      list expression
    • regexToLike

      public static Expression<String> regexToLike(Expression<String> expr)
      Convert the given expression from regex form to like
      Parameters:
      expr - expression to convert
      Returns:
      converted expression
    • neConst

      public static <D> Predicate neConst(Expression<D> left, D constant)
      Create a left != constant expression
      Type Parameters:
      D - type of expression
      Parameters:
      left - lhs of expression
      constant - rhs of expression
      Returns:
      left != constant
    • ne

      public static <D> Predicate ne(Expression<D> left, Expression<? super D> right)
      Create a left != right expression
      Type Parameters:
      D - type of expressions
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left != right
    • notIn

      public static <D> Predicate notIn(Expression<D> left, CollectionExpression<?,? extends D> right)
      Create a left not in right expression
      Type Parameters:
      D - type of expressions
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left not in right
    • notIn

      public static <D> Predicate notIn(Expression<D> left, SubQueryExpression<? extends D> right)
      Create a left not in right expression
      Type Parameters:
      D - type of expressions
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left not in right
    • notIn

      public static <D> Predicate notIn(Expression<D> left, Collection<? extends D> right)
      Create a left not in right expression
      Type Parameters:
      D - type of expressions
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left not in right
    • notInAny

      public static <D> Predicate notInAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists)
      Create a left not in right and... expression for each list
      Type Parameters:
      D -
      Parameters:
      left -
      lists -
      Returns:
      a left not in right and... expression
    • or

      public static Predicate or(Predicate left, Predicate right)
      Create a left or right expression
      Parameters:
      left - lhs of expression
      right - rhs of expression
      Returns:
      left or right
    • distinctList

      public static List<Expression<?>> distinctList(Expression<?>... args)
      Create a distinct list of the given args
      Parameters:
      args - elements
      Returns:
      list with distinct elements
    • distinctList

      public static List<Expression<?>> distinctList(Expression<?>[]... args)
      Create a distinct list of the concatenated array contents
      Parameters:
      args - elements
      Returns:
      list with distinct elements
    • extract

      public static <T> Expression<T> extract(Expression<T> expr)
      Get the potentially wrapped expression
      Parameters:
      expr - expression to analyze
      Returns:
      inner expression
    • createRootVariable

      public static String createRootVariable(Path<?> path, int suffix)
      Create a new root variable based on the given path and suffix
      Parameters:
      path - base path
      suffix - suffix for variable name
      Returns:
      path expression
    • createRootVariable

      public static String createRootVariable(Path<?> path)
      Create a new root variable based on the given path
      Parameters:
      path - base path
      Returns:
      variable name
    • toExpression

      public static Expression<?> toExpression(Object o)
      Converts the given object to an Expression

      Casts expressions and wraps everything else into co

      Parameters:
      o - object to convert
      Returns:
      converted argument
    • toLower

      public static Expression<String> toLower(Expression<String> stringExpression)
      Converts the given expression to lower(expression)

      Constants are lower()ed at creation time

      Parameters:
      stringExpression - the string to lower()
      Returns:
      lower(stringExpression)
    • orderBy

      public static Expression<?> orderBy(List<OrderSpecifier<?>> args)
      Create an expression out of the given order specifiers
      Parameters:
      args - order
      Returns:
      expression for order