org.qi4j.api.query
Class QueryExpressions

java.lang.Object
  extended by org.qi4j.api.query.QueryExpressions

public final class QueryExpressions
extends Object

Static factory methods for query expressions and operators.


Constructor Summary
QueryExpressions()
           
 
Method Summary
static Conjunction and(BooleanExpression left, BooleanExpression right, BooleanExpression... optionalRight)
          Conjunction factory method.
static
<T> ManyAssociationContainsPredicate<T>
contains(ManyAssociation<T> manyAssoc, T value)
           
static
<T,C extends Collection<T>>
ContainsPredicate<T,C>
contains(Property<C> property, T value)
           
static
<T,C extends Collection<T>>
ContainsAllPredicate<T,C>
containsAll(Property<C> property, C value)
           
static
<T> EqualsPredicate<String>
eq(Association<T> property, T value)
          EqualsPredicate factory method.
static
<T> EqualsPredicate<String>
eq(Association<T> property, VariableValueExpression<T> valueExpression)
          EqualsPredicate factory method.
static
<T> EqualsPredicate<T>
eq(Property<T> property, T value)
          EqualsPredicate factory method.
static
<T> EqualsPredicate<T>
eq(Property<T> property, VariableValueExpression<T> valueExpression)
          EqualsPredicate factory method.
static
<T> GreaterOrEqualPredicate<T>
ge(Property<T> property, T value)
          GreaterOrEqualPredicate factory method.
static
<T> GreaterOrEqualPredicate<T>
ge(Property<T> property, VariableValueExpression<T> valueExpression)
          GreaterOrEqualPredicate factory method.
static
<T> GreaterThanPredicate<T>
gt(Property<T> property, T value)
          GreaterThanPredicate factory method.
static
<T> GreaterThanPredicate<T>
gt(Property<T> property, VariableValueExpression<T> valueExpression)
          GreaterThanPredicate factory method.
static AssociationIsNotNullPredicate isNotNull(Association<?> association)
          AssociationIsNotNullPredicate factory method.
static
<T> PropertyIsNotNullPredicate<T>
isNotNull(Property<T> property)
          PropertyIsNotNullPredicate factory method.
static AssociationIsNullPredicate isNull(Association<?> association)
          AssociationIsNullPredicate factory method.
static
<T> PropertyIsNullPredicate<T>
isNull(Property<T> property)
          PropertyIsNullPredicate factory method.
static
<T> LessOrEqualPredicate<T>
le(Property<T> property, T value)
          LessOrEqualPredicate factory method.
static
<T> LessOrEqualPredicate<T>
le(Property<T> property, VariableValueExpression<T> valueExpression)
          LessOrEqualPredicate factory method.
static
<T> LessThanPredicate<T>
lt(Property<T> property, T value)
          LessThanPredicate factory method.
static
<T> LessThanPredicate<T>
lt(Property<T> property, VariableValueExpression<T> valueExpression)
          LessThanPredicate factory method.
static MatchesPredicate matches(Property<String> property, String regexp)
          MatchesPredicate factory method.
static Negation not(BooleanExpression expression)
          Negation factory method.
static
<T> NotEqualsPredicate<T>
notEq(Property<T> property, T value)
          NotEqualsPredicate factory method.
static
<T> NotEqualsPredicate<T>
notEq(Property<T> property, VariableValueExpression<T> valueExpression)
          NotEqualsPredicate factory method.
static
<T> T
oneOf(ManyAssociation<T> association)
          When querying for a member of an association, use this to get a template for a single element, which can then be used in expressions.
static Disjunction or(BooleanExpression left, BooleanExpression right, BooleanExpression... optionalRight)
          Disjunction factory method.
static
<T> OrderBy
orderBy(Property<T> property)
          OrderBy factory method (ascending order).
static
<T> OrderBy
orderBy(Property<T> property, OrderBy.Order order)
          OrderBy factory method.
static void setProvider(QueryExpressionsProvider provider)
          Set the provider to be used.
static
<T> T
templateFor(Class<T> mixinType)
          Creates a template for the a mixin type to be used to access properties in type safe fashion.
static
<T> T
templateFor(Class<T> mixinType, Object associatedEntity)
           
static
<T> VariableValueExpression<T>
variable(String name)
          VariableValueExpression factory method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryExpressions

public QueryExpressions()
Method Detail

setProvider

public static void setProvider(QueryExpressionsProvider provider)
Set the provider to be used. This is typically called by the runtime.

Parameters:
provider - the QueryExpressionsProvider

oneOf

public static <T> T oneOf(ManyAssociation<T> association)
When querying for a member of an association, use this to get a template for a single element, which can then be used in expressions.

Type Parameters:
T -
Parameters:
association -
Returns:

templateFor

public static <T> T templateFor(Class<T> mixinType)
Creates a template for the a mixin type to be used to access properties in type safe fashion.

Parameters:
mixinType - mixin type
Returns:
template instance

templateFor

public static <T> T templateFor(Class<T> mixinType,
                                Object associatedEntity)

variable

public static <T> VariableValueExpression<T> variable(String name)
VariableValueExpression factory method.

Parameters:
name - variable name; cannot be null
Returns:
an VariableValueExpression expression
Throws:
IllegalArgumentException - - If name is null or empty

isNull

public static <T> PropertyIsNullPredicate<T> isNull(Property<T> property)
PropertyIsNullPredicate factory method.

Parameters:
property - filtered property; cannot be null
Returns:
an PropertyIsNullPredicate expression
Throws:
IllegalArgumentException - - If property is null

isNull

public static AssociationIsNullPredicate isNull(Association<?> association)
AssociationIsNullPredicate factory method.

Parameters:
association - filtered association; cannot be null
Returns:
an AssociationIsNullPredicate expression
Throws:
IllegalArgumentException - - If association is null

isNotNull

public static <T> PropertyIsNotNullPredicate<T> isNotNull(Property<T> property)
PropertyIsNotNullPredicate factory method.

Parameters:
property - filtered property; cannot be null
Returns:
an PropertyIsNotNullPredicate expression
Throws:
IllegalArgumentException - - If property is null

isNotNull

public static AssociationIsNotNullPredicate isNotNull(Association<?> association)
AssociationIsNotNullPredicate factory method.

Parameters:
association - filtered association; cannot be null
Returns:
an AssociationIsNotNullPredicate expression
Throws:
IllegalArgumentException - - If association is null

eq

public static <T> EqualsPredicate<T> eq(Property<T> property,
                                        T value)
EqualsPredicate factory method.

Parameters:
property - filtered property; cannot be null
value - expected value that property is equal to; cannot be null
Returns:
an EqualsPredicate
Throws:
IllegalArgumentException - - If property or value are null

eq

public static <T> EqualsPredicate<T> eq(Property<T> property,
                                        VariableValueExpression<T> valueExpression)
EqualsPredicate factory method.

Parameters:
property - filtered property; cannot be null
valueExpression - expected value that property is equal to; cannot be null
Returns:
an EqualsPredicate
Throws:
IllegalArgumentException - - If property or value are null

eq

public static <T> EqualsPredicate<String> eq(Association<T> property,
                                             T value)
EqualsPredicate factory method.

Parameters:
property - filtered property; cannot be null
value - expected value that property is equal to; cannot be null
Returns:
an EqualsPredicate
Throws:
IllegalArgumentException - - If property or value are null

eq

public static <T> EqualsPredicate<String> eq(Association<T> property,
                                             VariableValueExpression<T> valueExpression)
EqualsPredicate factory method.

Parameters:
property - filtered property; cannot be null
valueExpression - expected value that property is equal to; cannot be null
Returns:
an EqualsPredicate
Throws:
IllegalArgumentException - - If property or value are null

notEq

public static <T> NotEqualsPredicate<T> notEq(Property<T> property,
                                              T value)
NotEqualsPredicate factory method.

Parameters:
property - filtered property; cannot be null
value - expected value that property is not equal to; cannot be null
Returns:
an NotEqualsPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

notEq

public static <T> NotEqualsPredicate<T> notEq(Property<T> property,
                                              VariableValueExpression<T> valueExpression)
NotEqualsPredicate factory method.

Parameters:
property - filtered property; cannot be null
valueExpression - expected value that property is not equal to; cannot be null
Returns:
an NotEqualsPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

lt

public static <T> LessThanPredicate<T> lt(Property<T> property,
                                          T value)
LessThanPredicate factory method.

Parameters:
property - filtered property; cannot be null
value - expected value that property is less than; cannot be null
Returns:
an LessThanPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

lt

public static <T> LessThanPredicate<T> lt(Property<T> property,
                                          VariableValueExpression<T> valueExpression)
LessThanPredicate factory method.

Parameters:
property - filtered property; cannot be null
valueExpression - expected value that property is less than; cannot be null
Returns:
an LessThanPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

le

public static <T> LessOrEqualPredicate<T> le(Property<T> property,
                                             T value)
LessOrEqualPredicate factory method.

Parameters:
property - filtered property; cannot be null
value - expected value that property is less than or equal to; cannot be null
Returns:
an LessOrEqualPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

le

public static <T> LessOrEqualPredicate<T> le(Property<T> property,
                                             VariableValueExpression<T> valueExpression)
LessOrEqualPredicate factory method.

Parameters:
property - filtered property; cannot be null
valueExpression - expected value that property is less than or equal to; cannot be null
Returns:
an LessOrEqualPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

gt

public static <T> GreaterThanPredicate<T> gt(Property<T> property,
                                             T value)
GreaterThanPredicate factory method.

Parameters:
property - filtered property; cannot be null
value - expected value that property is greater than; cannot be null
Returns:
an GreaterThanPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

gt

public static <T> GreaterThanPredicate<T> gt(Property<T> property,
                                             VariableValueExpression<T> valueExpression)
GreaterThanPredicate factory method.

Parameters:
property - filtered property; cannot be null
valueExpression - expected value that property is greater than; cannot be null
Returns:
an GreaterThanPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

ge

public static <T> GreaterOrEqualPredicate<T> ge(Property<T> property,
                                                T value)
GreaterOrEqualPredicate factory method.

Parameters:
property - filtered property; cannot be null
value - expected value that property is greater than or equal; cannot be null
Returns:
an GreaterOrEqualPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

ge

public static <T> GreaterOrEqualPredicate<T> ge(Property<T> property,
                                                VariableValueExpression<T> valueExpression)
GreaterOrEqualPredicate factory method.

Parameters:
property - filtered property; cannot be null
valueExpression - expected value that property is greater than or equal; cannot be null
Returns:
an GreaterOrEqualPredicate expression
Throws:
IllegalArgumentException - - If property or value are null

matches

public static MatchesPredicate matches(Property<String> property,
                                       String regexp)
MatchesPredicate factory method.

Parameters:
property - filtered property; cannot be null
regexp - expected regexp that property should match to; cannot be null
Returns:
an MatchesPredicate
Throws:
IllegalArgumentException - - If property or value are null

and

public static Conjunction and(BooleanExpression left,
                              BooleanExpression right,
                              BooleanExpression... optionalRight)
Conjunction factory method. Apply a logical "AND" between two (or more) boolean expressions. Also known as "conjunction".

Parameters:
left - left side boolean expression; cannot be null
right - right side boolean expression; cannot be null
optionalRight - optional additional right side boolean expressions
Returns:
an Conjunction operator
Throws:
IllegalArgumentException - - If left or right expressions are null

or

public static Disjunction or(BooleanExpression left,
                             BooleanExpression right,
                             BooleanExpression... optionalRight)
Disjunction factory method. Apply a logical "OR" between two (or more) boolean expressions. Also known as disjunction.

Parameters:
left - left side boolean expression; cannot be null
right - right side boolean expression; cannot be null
optionalRight - optional additional right side boolean expressions
Returns:
an Disjunction operator
Throws:
IllegalArgumentException - - If left or right expressions are null

not

public static Negation not(BooleanExpression expression)
Negation factory method. Apply a logical "NOT" to a boolean expression.

Parameters:
expression - boolean expression; cannot be null; cannot be null
Returns:
an Negation operator
Throws:
IllegalArgumentException - - If expression is null

contains

public static <T,C extends Collection<T>> ContainsPredicate<T,C> contains(Property<C> property,
                                                                          T value)

contains

public static <T> ManyAssociationContainsPredicate<T> contains(ManyAssociation<T> manyAssoc,
                                                               T value)

containsAll

public static <T,C extends Collection<T>> ContainsAllPredicate<T,C> containsAll(Property<C> property,
                                                                                C value)

orderBy

public static <T> OrderBy orderBy(Property<T> property)
OrderBy factory method (ascending order).

Parameters:
property - sorting property; cannot be null
Returns:
an OrderBy
Throws:
IllegalArgumentException - - If property is null

orderBy

public static <T> OrderBy orderBy(Property<T> property,
                                  OrderBy.Order order)
OrderBy factory method.

Parameters:
property - sorting property; cannot be null
order - sorting direction
Returns:
an OrderBy
Throws:
IllegalArgumentException - - If property is null