All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.persistence.criteria.CriteriaBuilder Maven / Gradle / Ivy

The newest version!
package javax.persistence.criteria;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.persistence.Tuple;

/**
 * Used to construct criteria queries, compound selections, expressions, predicates, orderings. Note that Predicate is used instead of
 * Expression in this API in order to work around the fact that Java generics are not compatible with varags.
 */
public interface CriteriaBuilder {

	/**
	 * Interface used to build general case expressions. Case conditions are evaluated in the order in which they are specified.
	 * 
	 * @param 
	 *            the type of the case
	 */
	public static interface Case extends Expression {

		/**
		 * Add an "else" clause to the case expression.
		 * 
		 * @param result
		 *            "else" result expression
		 * @return expression
		 */
		Expression otherwise(Expression result);

		/**
		 * Add an "else" clause to the case expression.
		 * 
		 * @param result
		 *            "else" result
		 * @return expression
		 */
		Expression otherwise(R result);

		/**
		 * Add a when/then clause to the case expression.
		 * 
		 * @param condition
		 *            "when" condition
		 * @param result
		 *            "then" result expression
		 * @return general case expression
		 */
		Case when(Expression condition, Expression result);

		/**
		 * Add a when/then clause to the case expression.
		 * 
		 * @param condition
		 *            "when" condition
		 * @param result
		 *            "then" result value
		 * @return general case expression
		 */
		Case when(Expression condition, R result);
	}

	/**
	 * Interface used to build coalesce expressions.
	 * 
	 * A coalesce expression is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of
	 * its first non-null argument otherwise.
	 * 
	 * @param 
	 *            the type of the coalesce
	 */
	public static interface Coalesce extends Expression {
		/**
		 * Add an argument to the coalesce expression.
		 * 
		 * @param value
		 *            expression
		 * @return coalesce expression
		 */
		Coalesce value(Expression value);

		/**
		 * Add an argument to the coalesce expression.
		 * 
		 * @param value
		 *            value
		 * @return coalesce expression
		 */
		Coalesce value(T value);
	}

	/**
	 * Interface used to build in predicates.
	 * 
	 * @param 
	 *            the type of the in
	 */
	public static interface In extends Predicate {
		/**
		 * Return the expression to be tested against the list of values.
		 * 
		 * @return expression
		 */
		Expression getExpression();

		/**
		 * Add to list of values to be tested against.
		 * 
		 * @param value
		 *            expression
		 * @return in predicate
		 */
		In value(Expression value);

		/**
		 * Add to list of values to be tested against.
		 * 
		 * @param value
		 *            value
		 * @return in predicate
		 */
		In value(T value);
	}

	/**
	 * Interface used to build simple case expressions. Case conditions are evaluated in the order in which they are specified.
	 * 
	 * @param 
	 *            the type of the case
	 * @param 
	 *            the type of the result
	 */
	public static interface SimpleCase extends Expression {
		/**
		 * Return the expression to be tested against the conditions.
		 * 
		 * @return expression
		 */
		Expression getExpression();

		/**
		 * Add an "else" clause to the case expression.
		 * 
		 * @param result
		 *            "else" result expression
		 * @return expression
		 */
		Expression otherwise(Expression result);

		/**
		 * Add an "else" clause to the case expression.
		 * 
		 * @param result
		 *            "else" result
		 * @return expression
		 */
		Expression otherwise(R result);

		/**
		 * Add a when/then clause to the case expression.
		 * 
		 * @param condition
		 *            "when" condition
		 * @param result
		 *            "then" result expression
		 * @return simple case expression
		 */
		SimpleCase when(C condition, Expression result);

		/**
		 * Add a when/then clause to the case expression.
		 * 
		 * @param condition
		 *            "when" condition
		 * @param result
		 *            "then" result value
		 * @return simple case expression
		 */
		SimpleCase when(C condition, R result);
	}

	/**
	 * Types for Trimspec.
	 * 
	 */
	public static enum Trimspec {
		/**
		 * Trim from leading end.
		 */
		LEADING,
		/**
		 * Trim from trailing end.
		 */
		TRAILING,
		/**
		 * Trim from both ends.
		 */
		BOTH
	}

	/**
	 * Create an expression that returns the absolute value of its argument.
	 * 
	 * @param x
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return absolute value
	 */
	 Expression abs(Expression x);

	/**
	 * Create an all expression over the subquery results.
	 * 
	 * @param subquery
	 * @param 
	 *            the type of the expression
	 * @return all expression
	 */
	 Expression all(Subquery subquery);

	/**
	 * Create a conjunction of the given boolean expressions.
	 * 
	 * @param x
	 *            boolean expression
	 * @param y
	 *            boolean expression
	 * @return and predicate
	 */
	Predicate and(Expression x, Expression y);

	/**
	 * Create a conjunction of the given restriction predicates. A conjunction of zero predicates is true.
	 * 
	 * @param restrictions
	 *            zero or more restriction predicates
	 * @return and predicate
	 */
	Predicate and(Predicate... restrictions);

	/**
	 * Create an any expression over the subquery results. This expression is equivalent to a some expression.
	 * 
	 * @param subquery
	 * @param 
	 *            the type of the expression
	 * @return any expression
	 */
	 Expression any(Subquery subquery);

	/**
	 * Create an array-valued selection item.
	 * 
	 * @param selections
	 *            selection items
	 * @return array-valued compound selection
	 * @throws IllegalArgumentException
	 *             if an argument is a tuple- or array-valued selection item
	 */
	CompoundSelection array(Selection... selections);

	/**
	 * Create an ordering by the ascending value of the expression.
	 * 
	 * @param x
	 *            expression used to define the ordering
	 * @return ascending ordering corresponding to the expression
	 */
	Order asc(Expression x);

	/**
	 * Create an aggregate expression applying the avg operation.
	 * 
	 * @param x
	 *            expression representing input value to avg operation
	 * @param 
	 *            the type of the expression
	 * @return avg expression
	 */
	 Expression avg(Expression x);

	/**
	 * Create a predicate for testing whether the first argument is between the second and third arguments in value.
	 * 
	 * @param v
	 *            expression
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return between predicate
	 */
	> Predicate between(Expression v, Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is between the second and third arguments in value.
	 * 
	 * @param v
	 *            expression
	 * @param x
	 *            value
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return between predicate
	 */
	> Predicate between(Expression v, Y x, Y y);

	/**
	 * Create a coalesce expression.
	 * 
	 * @param 
	 *            the type of the coalesce
	 * @return coalesce expression
	 */
	 Coalesce coalesce();

	/**
	 * Create an expression that returns null if all its arguments evaluate to null, and the value of the first non-null argument otherwise.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return coalesce expression
	 */
	 Expression coalesce(Expression x, Expression y);

	/**
	 * Create an expression that returns null if all its arguments evaluate to null, and the value of the first non-null argument otherwise.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return coalesce expression
	 */
	 Expression coalesce(Expression x, Y y);

	/**
	 * Create an expression for string concatenation.
	 * 
	 * @param x
	 *            string expression
	 * @param y
	 *            string expression
	 * @return expression corresponding to concatenation
	 */
	Expression concat(Expression x, Expression y);

	/**
	 * Create an expression for string concatenation.
	 * 
	 * @param x
	 *            string expression
	 * @param y
	 *            string
	 * @return expression corresponding to concatenation
	 */
	Expression concat(Expression x, String y);

	/**
	 * Create an expression for string concatenation.
	 * 
	 * @param x
	 *            string
	 * @param y
	 *            string expression
	 * @return expression corresponding to concatenation
	 */
	Expression concat(String x, Expression y);

	/**
	 * Create a conjunction (with zero conjuncts). A conjunction with zero conjuncts is true.
	 * 
	 * @return and predicate
	 */
	Predicate conjunction();

	/**
	 * Create a selection item corresponding to a constructor. This method is used to specify a constructor that will be applied to the
	 * results of the query execution. If the constructor is for an entity class, the resulting entities will be in the new state after the
	 * query is executed.
	 * 
	 * @param resultClass
	 *            class whose instance is to be constructed
	 * @param selections
	 *            arguments to the constructor
	 * @param 
	 *            the type of the selection
	 * @return compound selection item
	 * @throws IllegalArgumentException
	 *             if an argument is a tuple- or array-valued selection item
	 */
	 CompoundSelection construct(Class resultClass, Selection... selections);

	/**
	 * Create an aggregate expression applying the count operation.
	 * 
	 * @param x
	 *            expression representing input value to count operation
	 * @return count expression
	 */
	Expression count(Expression x);

	/**
	 * Create an aggregate expression applying the count distinct operation.
	 * 
	 * @param x
	 *            expression representing input value to count distinct operation
	 * @return count distinct expression
	 */
	Expression countDistinct(Expression x);

	/**
	 * Create a CriteriaQuery object.
	 * 
	 * @return criteria query object
	 */
	CriteriaQuery createQuery();

	/**
	 * Create a CriteriaQuery object with the specified result type.
	 * 
	 * @param resultClass
	 *            type of the query result
	 * @param 
	 *            the type of the criteria query
	 * @return criteria query object
	 */
	 CriteriaQuery createQuery(Class resultClass);

	/**
	 * Create a CriteriaQuery object that returns a tuple of objects as its result.
	 * 
	 * @return criteria query object
	 */
	CriteriaQuery createTupleQuery();

	/**
	 * Create expression to return current date.
	 * 
	 * @return expression for current date
	 */
	Expression currentDate();

	/**
	 * Create expression to return current time.
	 * 
	 * @return expression for current time
	 */
	Expression currentTime();

	/**
	 * Create expression to return current timestamp.
	 * 
	 * @return expression for current timestamp
	 */
	Expression currentTimestamp();

	/**
	 * Create an ordering by the descending value of the expression.
	 * 
	 * @param x
	 *            expression used to define the ordering
	 * @return descending ordering corresponding to the expression
	 */
	Order desc(Expression x);

	/**
	 * Create an expression that returns the difference between its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return difference
	 */
	 Expression diff(Expression x, Expression y);

	/**
	 * Create an expression that returns the difference between its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return difference
	 */
	 Expression diff(Expression x, N y);

	/**
	 * Create an expression that returns the difference between its arguments.
	 * 
	 * @param x
	 *            value
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return difference
	 */
	 Expression diff(N x, Expression y);

	/**
	 * Create a disjunction (with zero disjuncts). A disjunction with zero disjuncts is false.
	 * 
	 * @return or predicate
	 */
	Predicate disjunction();

	/**
	 * Create a predicate for testing the arguments for equality.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @return equality predicate
	 */
	Predicate equal(Expression x, Expression y);

	/**
	 * Create a predicate for testing the arguments for equality.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            object
	 * @return equality predicate
	 */
	Predicate equal(Expression x, Object y);

	/**
	 * Create a predicate testing the existence of a subquery result.
	 * 
	 * @param subquery
	 *            subquery whose result is to be tested
	 * @return exists predicate
	 */
	Predicate exists(Subquery subquery);

	/**
	 * Create an expression for the execution of a database function.
	 * 
	 * @param name
	 *            function name
	 * @param type
	 *            expected result type
	 * @param args
	 *            function arguments
	 * @param 
	 *            the type of the expression
	 * @return expression
	 */
	 Expression function(String name, Class type, Expression... args);

	/**
	 * Create a predicate for testing whether the first argument is greater than or equal to the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @return greater-than-or-equal predicate
	 */
	Predicate ge(Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is greater than or equal to the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @return greater-than-or-equal predicate
	 */
	Predicate ge(Expression x, Number y);

	/**
	 * Create a predicate for testing whether the first argument is greater than the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return greater-than predicate
	 */
	> Predicate greaterThan(Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is greater than the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return greater-than predicate
	 */
	> Predicate greaterThan(Expression x, Y y);

	/**
	 * Create a predicate for testing whether the first argument is greater than or equal to the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return greater-than-or-equal predicate
	 */
	> Predicate greaterThanOrEqualTo(Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is greater than or equal to the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return greater-than-or-equal predicate
	 */
	> Predicate greaterThanOrEqualTo(Expression x, Y y);

	/**
	 * Create an aggregate expression for finding the greatest of the values (strings, dates, etc).
	 * 
	 * @param x
	 *            expression representing input value to greatest operation
	 * @param 
	 *            the type of the expression
	 * @return greatest expression
	 */
	> Expression greatest(Expression x);

	/**
	 * Create a predicate for testing whether the first argument is greater than the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @return greater-than predicate
	 */
	Predicate gt(Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is greater than the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @return greater-than predicate
	 */
	Predicate gt(Expression x, Number y);

	/**
	 * Create predicate to test whether given expression is contained in a list of values.
	 * 
	 * @param expression
	 *            to be tested against list of values
	 * @param 
	 *            the type of the expression
	 * @return in predicate
	 */
	 In in(Expression expression);

	/**
	 * Create a predicate that tests whether a collection is empty.
	 * 
	 * @param collection
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return is-empty predicate
	 */
	> Predicate isEmpty(Expression collection);

	/**
	 * Create a predicate testing for a false value.
	 * 
	 * @param x
	 *            expression to be tested
	 * @return predicate
	 */
	Predicate isFalse(Expression x);

	/**
	 * Create a predicate that tests whether an element is a member of a collection. If the collection is empty, the predicate will be
	 * false.
	 * 
	 * @param elem
	 *            element
	 * @param collection
	 *            expression
	 * @param 
	 *            the type of the element
	 * @param 
	 *            the type of the collection
	 * @return is-member predicate
	 */
	> Predicate isMember(E elem, Expression collection);

	/**
	 * Create a predicate that tests whether an element is a member of a collection. If the collection is empty, the predicate will be
	 * false.
	 * 
	 * @param elem
	 *            element expression
	 * @param collection
	 *            expression
	 * @param 
	 *            the type of the element
	 * @param 
	 *            the type of the collection
	 * @return is-member predicate
	 */
	> Predicate isMember(Expression elem, Expression collection);

	/**
	 * Create a predicate that tests whether a collection is not empty.
	 * 
	 * @param collection
	 *            expression
	 * @param 
	 *            the type of the collection
	 * @return is-not-empty predicate
	 */
	> Predicate isNotEmpty(Expression collection);

	/**
	 * Create a predicate that tests whether an element is not a member of a collection. If the collection is empty, the predicate will be
	 * true.
	 * 
	 * @param elem
	 *            element
	 * @param collection
	 *            expression
	 * @param 
	 *            the type of the element
	 * @param 
	 *            the type of the collection
	 * @return is-not-member predicate
	 */
	> Predicate isNotMember(E elem, Expression collection);

	/**
	 * Create a predicate that tests whether an element is not a member of a collection. If the collection is empty, the predicate will be
	 * true.
	 * 
	 * @param elem
	 *            element expression
	 * @param collection
	 *            expression
	 * @param 
	 *            the type of the element
	 * @param 
	 *            the type of the collection
	 * @return is-not-member predicate
	 */
	> Predicate isNotMember(Expression elem, Expression collection);

	/**
	 * Create a predicate to test whether the expression is not null.
	 * 
	 * @param x
	 *            expression
	 * @return is-not-null predicate
	 */
	Predicate isNotNull(Expression x);

	/**
	 * Create a predicate to test whether the expression is null.
	 * 
	 * @param x
	 *            expression
	 * @return is-null predicate
	 */
	Predicate isNull(Expression x);

	/**
	 * Create a predicate testing for a true value.
	 * 
	 * @param x
	 *            expression to be tested
	 * @return predicate
	 */
	Predicate isTrue(Expression x);

	/**
	 * Create an expression that returns the keys of a map.
	 * 
	 * @param map
	 *            map
	 * @param 
	 *            the type of the key
	 * @param 
	 *            the type of the map
	 * @return set expression
	 */
	> Expression> keys(M map);

	/**
	 * Create a predicate for testing whether the first argument is less than or equal to the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @return less-than-or-equal predicate
	 */
	Predicate le(Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is less than or equal to the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @return less-than-or-equal predicate
	 */
	Predicate le(Expression x, Number y);

	/**
	 * Create an aggregate expression for finding the least of the values (strings, dates, etc).
	 * 
	 * @param x
	 *            expression representing input value to least operation
	 * @param 
	 *            the type of the expression
	 * @return least expression
	 */
	> Expression least(Expression x);

	/**
	 * Create expression to return length of a string.
	 * 
	 * @param x
	 *            string expression
	 * @return length expression
	 */
	Expression length(Expression x);

	/**
	 * Create a predicate for testing whether the first argument is less than the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return less-than predicate
	 */
	> Predicate lessThan(Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is less than the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return less-than predicate
	 */
	> Predicate lessThan(Expression x, Y y);

	/**
	 * Create a predicate for testing whether the first argument is less than or equal to the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return less-than-or-equal predicate
	 */
	> Predicate lessThanOrEqualTo(Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is less than or equal to the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return less-than-or-equal predicate
	 */
	> Predicate lessThanOrEqualTo(Expression x, Y y);

	/**
	 * Create a predicate for testing whether the expression satisfies the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string expression
	 * @return like predicate
	 */
	Predicate like(Expression x, Expression pattern);

	/**
	 * Create a predicate for testing whether the expression satisfies the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string expression
	 * @param escapeChar
	 *            escape character
	 * @return like predicate
	 */
	Predicate like(Expression x, Expression pattern, char escapeChar);

	/**
	 * Create a predicate for testing whether the expression satisfies the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string expression
	 * @param escapeChar
	 *            escape character expression
	 * @return like predicate
	 */
	Predicate like(Expression x, Expression pattern, Expression escapeChar);

	/**
	 * Create a predicate for testing whether the expression satisfies the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string
	 * @return like predicate
	 */
	Predicate like(Expression x, String pattern);

	/**
	 * Create a predicate for testing whether the expression satisfies the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string
	 * @param escapeChar
	 *            escape character
	 * @return like predicate
	 */
	Predicate like(Expression x, String pattern, char escapeChar);

	/**
	 * Create a predicate for testing whether the expression satisfies the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string
	 * @param escapeChar
	 *            escape character expression
	 * @return like predicate
	 */
	Predicate like(Expression x, String pattern, Expression escapeChar);

	/**
	 * Create an expression for a literal.
	 * 
	 * @param value
	 *            value represented by the expression
	 * @return expression literal
	 * @param 
	 *            the type of the expression
	 * @throws IllegalArgumentException
	 *             if value is null
	 */
	 Expression literal(T value);

	/**
	 * Create expression to locate the position of one string within another, returning position of first character if found. The first
	 * position in a string is denoted by 1. If the string to be located is not found, 0 is returned.
	 * 
	 * @param x
	 *            expression for string to be searched
	 * @param pattern
	 *            expression for string to be located
	 * @return expression corresponding to position
	 */
	Expression locate(Expression x, Expression pattern);

	/**
	 * Create expression to locate the position of one string within another, returning position of first character if found. The first
	 * position in a string is denoted by 1. If the string to be located is not found, 0 is returned.
	 * 
	 * @param x
	 *            expression for string to be searched
	 * @param pattern
	 *            expression for string to be located
	 * @param from
	 *            expression for position at which to start search
	 * @return expression corresponding to position
	 */
	Expression locate(Expression x, Expression pattern, Expression from);

	/**
	 * Create expression to locate the position of one string within another, returning position of first character if found. The first
	 * position in a string is denoted by 1. If the string to be located is not found, 0 is returned.
	 * 
	 * @param x
	 *            expression for string to be searched
	 * @param pattern
	 *            string to be located
	 * @return expression corresponding to position
	 */
	Expression locate(Expression x, String pattern);

	/**
	 * Create expression to locate the position of one string within another, returning position of first character if found. The first
	 * position in a string is denoted by 1. If the string to be located is not found, 0 is returned.
	 * 
	 * @param x
	 *            expression for string to be searched
	 * @param pattern
	 *            string to be located
	 * @param from
	 *            position at which to start search
	 * @return expression corresponding to position
	 */
	Expression locate(Expression x, String pattern, int from);

	/**
	 * Create expression for converting a string to lowercase.
	 * 
	 * @param x
	 *            string expression
	 * @return expression to convert to lowercase
	 */
	Expression lower(Expression x);

	/**
	 * Create a predicate for testing whether the first argument is less than the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @return less-than predicate
	 */
	Predicate lt(Expression x, Expression y);

	/**
	 * Create a predicate for testing whether the first argument is less than the second.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @return less-than predicate
	 */
	Predicate lt(Expression x, Number y);

	/**
	 * Create an aggregate expression applying the numerical max operation.
	 * 
	 * @param x
	 *            expression representing input value to max operation
	 * @param 
	 *            the type of the expression
	 * @return max expression
	 */
	 Expression max(Expression x);

	/**
	 * Create an aggregate expression applying the numerical min operation.
	 * 
	 * @param x
	 *            expression representing input value to min operation
	 * @param 
	 *            the type of the expression
	 * @return min expression
	 */
	 Expression min(Expression x);

	/**
	 * Create an expression that returns the modulus of its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @return modulus
	 */
	Expression mod(Expression x, Expression y);

	/**
	 * Create an expression that returns the modulus of its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @return modulus
	 */
	Expression mod(Expression x, Integer y);

	/**
	 * Create an expression that returns the modulus of its arguments.
	 * 
	 * @param x
	 *            value
	 * @param y
	 *            expression
	 * @return modulus
	 */
	Expression mod(Integer x, Expression y);

	/**
	 * Create an expression that returns the arithmetic negation of its argument.
	 * 
	 * @param x
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return arithmetic negation
	 */
	 Expression neg(Expression x);

	/**
	 * Create a negation of the given restriction.
	 * 
	 * @param restriction
	 *            restriction expression
	 * @return not predicate
	 */
	Predicate not(Expression restriction);

	/**
	 * Create a predicate for testing the arguments for inequality.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @return inequality predicate
	 */
	Predicate notEqual(Expression x, Expression y);

	/**
	 * Create a predicate for testing the arguments for inequality.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            object
	 * @return inequality predicate
	 */
	Predicate notEqual(Expression x, Object y);

	/**
	 * Create a predicate for testing whether the expression does not satisfy the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string expression
	 * @return not-like predicate
	 */
	Predicate notLike(Expression x, Expression pattern);

	/**
	 * Create a predicate for testing whether the expression does not satisfy the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string expression
	 * @param escapeChar
	 *            escape character
	 * @return not-like predicate
	 */
	Predicate notLike(Expression x, Expression pattern, char escapeChar);

	/**
	 * Create a predicate for testing whether the expression does not satisfy the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string expression
	 * @param escapeChar
	 *            escape character expression
	 * @return not-like predicate
	 */
	Predicate notLike(Expression x, Expression pattern, Expression escapeChar);

	/**
	 * Create a predicate for testing whether the expression does not satisfy the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string
	 * @return not-like predicate
	 */
	Predicate notLike(Expression x, String pattern);

	/**
	 * Create a predicate for testing whether the expression does not satisfy the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string
	 * @param escapeChar
	 *            escape character
	 * @return not-like predicate
	 */
	Predicate notLike(Expression x, String pattern, char escapeChar);

	/**
	 * Create a predicate for testing whether the expression does not satisfy the given pattern.
	 * 
	 * @param x
	 *            string expression
	 * @param pattern
	 *            string
	 * @param escapeChar
	 *            escape character expression
	 * @return not-like predicate
	 */
	Predicate notLike(Expression x, String pattern, Expression escapeChar);

	/**
	 * Create an expression that tests whether its argument are equal, returning null if they are and the value of the first expression if
	 * they are not.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return nullif expression
	 */
	 Expression nullif(Expression x, Expression y);

	/**
	 * Create an expression that tests whether its argument are equal, returning null if they are and the value of the first expression if
	 * they are not.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return nullif expression
	 */
	 Expression nullif(Expression x, Y y);

	/**
	 * Create an expression for a null literal with the given type.
	 * 
	 * @param resultClass
	 *            type of the null literal
	 * @param 
	 *            the type of the expression
	 * @return null expression literal
	 */
	 Expression nullLiteral(Class resultClass);

	/**
	 * Create a disjunction of the given boolean expressions.
	 * 
	 * @param x
	 *            boolean expression
	 * @param y
	 *            boolean expression
	 * @return or predicate
	 */
	Predicate or(Expression x, Expression y);

	/**
	 * Create a disjunction of the given restriction predicates. A disjunction of zero predicates is false.
	 * 
	 * @param restrictions
	 *            zero or more restriction predicates
	 * @return or predicate
	 */
	Predicate or(Predicate... restrictions);

	/**
	 * Create a parameter expression.
	 * 
	 * @param paramClass
	 *            parameter class
	 * @param 
	 *            the type of the expression
	 * @return parameter expression
	 */
	 ParameterExpression parameter(Class paramClass);

	/**
	 * Create a parameter expression with the given name.
	 * 
	 * @param paramClass
	 *            parameter class
	 * @param name
	 *            name that can be used to refer to the parameter
	 * @param 
	 *            the type of the expression
	 * @return parameter expression
	 */
	 ParameterExpression parameter(Class paramClass, String name);

	/**
	 * Create an expression that returns the product of its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return product
	 */
	 Expression prod(Expression x, Expression y);

	/**
	 * Create an expression that returns the product of its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return product
	 */
	 Expression prod(Expression x, N y);

	/**
	 * Create an expression that returns the product of its arguments.
	 * 
	 * @param x
	 *            value
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return product
	 */
	 Expression prod(N x, Expression y);

	/**
	 * Create an expression that returns the quotient of its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @return quotient
	 */
	Expression quot(Expression x, Expression y);

	/**
	 * Create an expression that returns the quotient of its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @return quotient
	 */
	Expression quot(Expression x, Number y);

	/**
	 * Create an expression that returns the quotient of its arguments.
	 * 
	 * @param x
	 *            value
	 * @param y
	 *            expression
	 * @return quotient
	 */
	Expression quot(Number x, Expression y);

	/**
	 * Create a general case expression.
	 * 
	 * @param 
	 *            the type of the result
	 * @return general case expression
	 */
	 Case selectCase();

	/**
	 * Create a simple case expression.
	 * 
	 * @param expression
	 *            to be tested against the case conditions
	 * @param 
	 *            the type of the case
	 * @param 
	 *            the type of the result
	 * @return simple case expression
	 */
	 SimpleCase selectCase(Expression expression);

	/**
	 * Create an expression that tests the size of a collection.
	 * 
	 * @param collection
	 *            collection
	 * @param 
	 *            the type of the collection
	 * @return size expression
	 */
	> Expression size(C collection);

	/**
	 * Create an expression that tests the size of a collection.
	 * 
	 * @param collection
	 *            expression
	 * @param 
	 *            the type of the collection
	 * @return size expression
	 */
	> Expression size(Expression collection);

	/**
	 * Create a some expression over the subquery results. This expression is equivalent to an any expression.
	 * 
	 * @param subquery
	 * @param 
	 *            the type of the expression
	 * @return some expression
	 */
	 Expression some(Subquery subquery);

	/**
	 * Create an expression that returns the square root of its argument.
	 * 
	 * @param x
	 *            expression
	 * @return square root
	 */
	Expression sqrt(Expression x);

	/**
	 * Create an expression for substring extraction. Extracts a substring starting at the specified position through to end of the string.
	 * First position is 1.
	 * 
	 * @param x
	 *            string expression
	 * @param from
	 *            start position expression
	 * @return expression corresponding to substring extraction
	 */
	Expression substring(Expression x, Expression from);

	/**
	 * Create an expression for substring extraction. Extracts a substring of given length starting at the specified position. First
	 * position is 1.
	 * 
	 * @param x
	 *            string expression
	 * @param from
	 *            start position expression
	 * @param len
	 *            length expression
	 * @return expression corresponding to substring extraction
	 */
	Expression substring(Expression x, Expression from, Expression len);

	/**
	 * Create an expression for substring extraction. Extracts a substring starting at the specified position through to end of the string.
	 * First position is 1.
	 * 
	 * @param x
	 *            string expression
	 * @param from
	 *            start position
	 * @return expression corresponding to substring extraction
	 */
	Expression substring(Expression x, int from);

	/**
	 * Create an expression for substring extraction. Extracts a substring of given length starting at the specified position. First
	 * position is 1.
	 * 
	 * @param x
	 *            string expression
	 * @param from
	 *            start position
	 * @param len
	 *            length
	 * @return expression corresponding to substring extraction
	 */
	Expression substring(Expression x, int from, int len);

	/**
	 * Create an expression that returns the sum of its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return sum
	 */
	 Expression sum(Expression x, Expression y);

	/**
	 * Create an expression that returns the sum of its arguments.
	 * 
	 * @param x
	 *            expression
	 * @param y
	 *            value
	 * @param 
	 *            the type of the expression
	 * @return sum
	 */
	 Expression sum(Expression x, N y);

	/**
	 * Create an aggregate expression applying the sum operation.
	 * 
	 * @param x
	 *            expression representing input value to sum operation
	 * @param 
	 *            the type of the expression
	 * @return sum expression
	 */
	 Expression sum(Expression x);

	/**
	 * Create an expression that returns the sum of its arguments.
	 * 
	 * @param x
	 *            value
	 * @param y
	 *            expression
	 * @param 
	 *            the type of the expression
	 * @return sum
	 */
	 Expression sum(N x, Expression y);

	/**
	 * Create an aggregate expression applying the sum operation to a Float-valued expression, returning a Double result.
	 * 
	 * @param x
	 *            expression representing input value to sum operation
	 * @return sum expression
	 */
	Expression sumAsDouble(Expression x);

	/**
	 * Create an aggregate expression applying the sum operation to an Integer-valued expression, returning a Long result.
	 * 
	 * @param x
	 *            expression representing input value to sum operation
	 * @return sum expression
	 */
	Expression sumAsLong(Expression x);

	/**
	 * Typecast. Returns same expression object.
	 * 
	 * @param number
	 *            numeric expression
	 * @return Expression
	 */
	Expression toBigDecimal(Expression number);

	/**
	 * Typecast. Returns same expression object.
	 * 
	 * @param number
	 *            numeric expression
	 * @return Expression
	 */
	Expression toBigInteger(Expression number);

	/**
	 * Typecast. Returns same expression object.
	 * 
	 * @param number
	 *            numeric expression
	 * @return Expression
	 */
	Expression toDouble(Expression number);

	/**
	 * Typecast. Returns same expression object.
	 * 
	 * @param number
	 *            numeric expression
	 * @return Expression
	 */
	Expression toFloat(Expression number);

	/**
	 * Typecast. Returns same expression object.
	 * 
	 * @param number
	 *            numeric expression
	 * @return Expression
	 */
	Expression toInteger(Expression number);

	/**
	 * Typecast. Returns same expression object.
	 * 
	 * @param number
	 *            numeric expression
	 * @return Expression
	 */
	Expression toLong(Expression number);

	/**
	 * Typecast. Returns same expression object.
	 * 
	 * @param character
	 *            expression
	 * @return Expression
	 */
	Expression toString(Expression character);

	/**
	 * Create expression to trim character from both ends of a string.
	 * 
	 * @param t
	 *            character to be trimmed
	 * @param x
	 *            expression for string to trim
	 * @return trim expression
	 */
	Expression trim(char t, Expression x);

	/**
	 * Create expression to trim character from both ends of a string.
	 * 
	 * @param t
	 *            expression for character to be trimmed
	 * @param x
	 *            expression for string to trim
	 * @return trim expression
	 */
	Expression trim(Expression t, Expression x);

	/**
	 * Create expression to trim blanks from both ends of a string.
	 * 
	 * @param x
	 *            expression for string to trim
	 * @return trim expression
	 */
	Expression trim(Expression x);

	/**
	 * Create expression to trim character from a string.
	 * 
	 * @param ts
	 *            trim specification
	 * @param t
	 *            character to be trimmed
	 * @param x
	 *            expression for string to trim
	 * @return trim expression
	 */
	Expression trim(Trimspec ts, char t, Expression x);

	/**
	 * Create expression to trim character from a string.
	 * 
	 * @param ts
	 *            trim specification
	 * @param t
	 *            expression for character to be trimmed
	 * @param x
	 *            expression for string to trim
	 * @return trim expression
	 */
	Expression trim(Trimspec ts, Expression t, Expression x);

	/**
	 * Create expression to trim blanks from a string.
	 * 
	 * @param ts
	 *            trim specification
	 * @param x
	 *            expression for string to trim
	 * @return trim expression
	 */
	Expression trim(Trimspec ts, Expression x);

	/**
	 * Create a tuple-valued selection item.
	 * 
	 * @param selections
	 *            selection items
	 * @return tuple-valued compound selection
	 * @throws IllegalArgumentException
	 *             if an argument is a tuple- or array-valued selection item
	 */
	CompoundSelection tuple(Selection... selections);

	/**
	 * Create expression for converting a string to uppercase.
	 * 
	 * @param x
	 *            string expression
	 * @return expression to convert to uppercase
	 */
	Expression upper(Expression x);

	/**
	 * Create an expression that returns the values of a map.
	 * 
	 * @param map
	 *            map
	 * @param 
	 *            type of the value
	 * @param 
	 *            type of the map
	 * @return collection expression
	 */
	> Expression> values(M map);
}