org.qi4j.api.query
Class QueryExpressions

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

public final class QueryExpressions
extends java.lang.Object

Static factory methods for query expressions and operators.


Constructor Summary
QueryExpressions()
           
 
Method Summary
static AndSpecification and(Specification<Composite> left, Specification<Composite> right, Specification<Composite>... optionalRight)
          Create a new AND specification.
static
<T> AssociationFunction<T>
association(Association<T> association)
          Create a new Query Template AssociationFunction.
static
<T> ManyAssociationContainsSpecification<T>
contains(ManyAssociation<T> manyAssoc, T value)
          Create a new CONTAINS specification for a ManyAssociation.
static
<T> ContainsSpecification<T>
contains(Property<? extends java.util.Collection<T>> collectionProperty, T value)
          Create a new CONTAINS specification for a Collection Property.
static
<T> ContainsSpecification<T>
contains(Property<? extends java.util.Collection<T>> collectionProperty, Variable variable)
          Create a new CONTAINS specification for a Collection Property using named Variables.
static
<T> ContainsAllSpecification<T>
containsAll(Property<? extends java.util.Collection<T>> collectionProperty, java.lang.Iterable<T> values)
          Create a new CONTAINS ALL specification for a Collection Property.
static
<T> ContainsAllSpecification<T>
containsAllVariables(Property<? extends java.util.Collection<T>> collectionProperty, java.lang.Iterable<Variable> variables)
          Create a new CONTAINS ALL specification for a Collection Property using named Variables.
static
<T> EqSpecification<java.lang.String>
eq(Association<T> association, T value)
          Create a new EQUALS specification for an Association.
static
<T> EqSpecification<T>
eq(Property<T> property, T value)
          Create a new EQUALS specification for a Property.
static
<T> EqSpecification<T>
eq(Property<T> property, Variable variable)
          Create a new EQUALS specification for a Property using a named Variable.
static
<T> GeSpecification<T>
ge(Property<T> property, T value)
          Create a new GREATER OR EQUALS specification for a Property.
static
<T> GeSpecification<T>
ge(Property<T> property, Variable variable)
          Create a new GREATER OR EQUALS specification for a Property using a named Variable.
static
<T> GtSpecification<T>
gt(Property<T> property, T value)
          Create a new GREATER THAN specification for a Property.
static
<T> GtSpecification<T>
gt(Property<T> property, Variable variable)
          Create a new GREATER THAN specification for a Property using a named Variable.
static
<T> AssociationNotNullSpecification<T>
isNotNull(Association<T> association)
          Create a new NOT NULL specification for an Association.
static
<T> PropertyNotNullSpecification<T>
isNotNull(Property<T> property)
          Create a new NOT NULL specification for a Property.
static
<T> AssociationNullSpecification<T>
isNull(Association<T> association)
          Create a new NULL specification for an Association.
static
<T> PropertyNullSpecification<T>
isNull(Property<T> property)
          Create a new NULL specification for a Property.
static
<T> LeSpecification<T>
le(Property<T> property, T value)
          Create a new LESS OR EQUALS specification for a Property.
static
<T> LeSpecification<T>
le(Property<T> property, Variable variable)
          Create a new LESS OR EQUALS specification for a Property using a named Variable.
static
<T> LtSpecification<T>
lt(Property<T> property, T value)
          Create a new LESSER THAN specification for a Property.
static
<T> LtSpecification<T>
lt(Property<T> property, Variable variable)
          Create a new LESSER THAN specification for a Property using a named Variable.
static
<T> ManyAssociationFunction<T>
manyAssociation(ManyAssociation<T> association)
          Create a new Query Template ManyAssociationFunction.
static MatchesSpecification matches(Property<java.lang.String> property, java.lang.String regexp)
          Create a new REGULAR EXPRESSION specification for a Property.
static MatchesSpecification matches(Property<java.lang.String> property, Variable variable)
          Create a new REGULAR EXPRESSION specification for a Property using a named Variable.
static
<T> NeSpecification<T>
ne(Property<T> property, T value)
          Create a new NOT EQUALS specification for a Property.
static
<T> NeSpecification<T>
ne(Property<T> property, Variable variable)
          Create a new NOT EQUALS specification for a Property using a named Variable.
static NotSpecification not(Specification<Composite> operand)
          Create a new NOT specification.
static
<T> T
oneOf(ManyAssociation<T> association)
           
static OrSpecification or(Specification<Composite> left, Specification<Composite> right, Specification<Composite>... optionalRight)
          Create a new OR specification.
static
<T> OrderBy
orderBy(Property<T> property)
          Create a new Query ascending order segment for a Property.
static
<T> OrderBy
orderBy(Property<T> property, OrderBy.Order order)
          Create a new Query ordering segment for a Property.
static
<T> Property<T>
property(java.lang.Class<?> mixinClass, java.lang.String fieldName)
          Create a new Query Property instance.
static
<T> PropertyFunction<T>
property(Property<T> property)
          Create a new Query Template PropertyFunction.
static
<T> T
templateFor(java.lang.Class<T> clazz)
          Create a Query Template using the given type.
static
<T> T
templateFor(java.lang.Class<T> mixinType, Association<?> association)
          Create a Query Template using the given mixin class and association.
static Variable variable(java.lang.String name)
          Create a new Query Variable.
 
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

templateFor

public static <T> T templateFor(java.lang.Class<T> clazz)
Create a Query Template using the given type.

Type Parameters:
T - the type of the template
Parameters:
clazz - a class declaring the type of the template
Returns:
a new Query Template

templateFor

public static <T> T templateFor(java.lang.Class<T> mixinType,
                                Association<?> association)
Create a Query Template using the given mixin class and association.

Type Parameters:
T - the type of the template
Parameters:
mixinType - a class declaring the type of the template
association - an association
Returns:
a new Query Template

oneOf

public static <T> T oneOf(ManyAssociation<T> association)

variable

public static Variable variable(java.lang.String name)
Create a new Query Variable.

Parameters:
name - a name for the Variable
Returns:
a new Query Variable.

property

public static <T> PropertyFunction<T> property(Property<T> property)
Create a new Query Template PropertyFunction.

Type Parameters:
T - type of the Property
Parameters:
property - a Property
Returns:
a new Query Template PropertyFunction

property

public static <T> Property<T> property(java.lang.Class<?> mixinClass,
                                       java.lang.String fieldName)
Create a new Query Property instance.

Type Parameters:
T - type of the Property
Parameters:
mixinClass - mixin of the Property
fieldName - name of the Property field
Returns:
a new Query Property instance for the given mixin and property name.

association

public static <T> AssociationFunction<T> association(Association<T> association)
Create a new Query Template AssociationFunction.

Type Parameters:
T - type of the Association
Parameters:
association - an Association
Returns:
a new Query Template AssociationFunction

manyAssociation

public static <T> ManyAssociationFunction<T> manyAssociation(ManyAssociation<T> association)
Create a new Query Template ManyAssociationFunction.

Type Parameters:
T - type of the ManyAssociation
Parameters:
association - a ManyAssociation
Returns:
a new Query Template ManyAssociationFunction

and

public static AndSpecification and(Specification<Composite> left,
                                   Specification<Composite> right,
                                   Specification<Composite>... optionalRight)
Create a new AND specification.

Parameters:
left - first operand
right - second operand
optionalRight - optional operands
Returns:
a new AND specification

or

public static OrSpecification or(Specification<Composite> left,
                                 Specification<Composite> right,
                                 Specification<Composite>... optionalRight)
Create a new OR specification.

Parameters:
left - first operand
right - second operand
optionalRight - optional operands
Returns:
a new OR specification

not

public static NotSpecification not(Specification<Composite> operand)
Create a new NOT specification.

Parameters:
operand - specification to be negated
Returns:
a new NOT specification

eq

public static <T> EqSpecification<T> eq(Property<T> property,
                                        T value)
Create a new EQUALS specification for a Property.

Parameters:
property - a Property
value - its value
Returns:
a new EQUALS specification for a Property.

eq

public static <T> EqSpecification<T> eq(Property<T> property,
                                        Variable variable)
Create a new EQUALS specification for a Property using a named Variable.

Parameters:
property - a Property
variable - a Query Variable
Returns:
a new EQUALS specification for a Property using a named Variable.

eq

public static <T> EqSpecification<java.lang.String> eq(Association<T> association,
                                                       T value)
Create a new EQUALS specification for an Association.

Parameters:
association - an Association
value - its value
Returns:
a new EQUALS specification for an Association.

ge

public static <T> GeSpecification<T> ge(Property<T> property,
                                        T value)
Create a new GREATER OR EQUALS specification for a Property.

Parameters:
property - a Property
value - its value
Returns:
a new GREATER OR EQUALS specification for a Property.

ge

public static <T> GeSpecification<T> ge(Property<T> property,
                                        Variable variable)
Create a new GREATER OR EQUALS specification for a Property using a named Variable.

Parameters:
property - a Property
variable - a Query Variable
Returns:
a new GREATER OR EQUALS specification for a Property using a named Variable.

gt

public static <T> GtSpecification<T> gt(Property<T> property,
                                        T value)
Create a new GREATER THAN specification for a Property.

Parameters:
property - a Property
value - its value
Returns:
a new GREATER THAN specification for a Property.

gt

public static <T> GtSpecification<T> gt(Property<T> property,
                                        Variable variable)
Create a new GREATER THAN specification for a Property using a named Variable.

Parameters:
property - a Property
variable - a Query Variable
Returns:
a new GREATER THAN specification for a Property using a named Variable.

le

public static <T> LeSpecification<T> le(Property<T> property,
                                        T value)
Create a new LESS OR EQUALS specification for a Property.

Parameters:
property - a Property
value - its value
Returns:
a new LESS OR EQUALS specification for a Property.

le

public static <T> LeSpecification<T> le(Property<T> property,
                                        Variable variable)
Create a new LESS OR EQUALS specification for a Property using a named Variable.

Parameters:
property - a Property
variable - a Query Variable
Returns:
a new LESS OR EQUALS specification for a Property using a named Variable.

lt

public static <T> LtSpecification<T> lt(Property<T> property,
                                        T value)
Create a new LESSER THAN specification for a Property.

Parameters:
property - a Property
value - its value
Returns:
a new LESSER THAN specification for a Property.

lt

public static <T> LtSpecification<T> lt(Property<T> property,
                                        Variable variable)
Create a new LESSER THAN specification for a Property using a named Variable.

Parameters:
property - a Property
variable - a Query Variable
Returns:
a new LESSER THAN specification for a Property using a named Variable.

ne

public static <T> NeSpecification<T> ne(Property<T> property,
                                        T value)
Create a new NOT EQUALS specification for a Property.

Parameters:
property - a Property
value - its value
Returns:
a new NOT EQUALS specification for a Property.

ne

public static <T> NeSpecification<T> ne(Property<T> property,
                                        Variable variable)
Create a new NOT EQUALS specification for a Property using a named Variable.

Parameters:
property - a Property
variable - a Query Variable
Returns:
a new NOT EQUALS specification for a Property using a named Variable.

matches

public static MatchesSpecification matches(Property<java.lang.String> property,
                                           java.lang.String regexp)
Create a new REGULAR EXPRESSION specification for a Property.

Parameters:
property - a Property
regexp - its value
Returns:
a new REGULAR EXPRESSION specification for a Property.

matches

public static MatchesSpecification matches(Property<java.lang.String> property,
                                           Variable variable)
Create a new REGULAR EXPRESSION specification for a Property using a named Variable.

Parameters:
property - a Property
variable - a Query Variable
Returns:
a new REGULAR EXPRESSION specification for a Property using a named Variable.

isNotNull

public static <T> PropertyNotNullSpecification<T> isNotNull(Property<T> property)
Create a new NOT NULL specification for a Property.

Parameters:
property - a Property
Returns:
a new NOT NULL specification for a Property.

isNull

public static <T> PropertyNullSpecification<T> isNull(Property<T> property)
Create a new NULL specification for a Property.

Parameters:
property - a Property
Returns:
a new NULL specification for a Property.

isNotNull

public static <T> AssociationNotNullSpecification<T> isNotNull(Association<T> association)
Create a new NOT NULL specification for an Association.

Parameters:
association - an Association
Returns:
a new NOT NULL specification for an Association.

isNull

public static <T> AssociationNullSpecification<T> isNull(Association<T> association)
Create a new NULL specification for an Association.

Parameters:
association - an Association
Returns:
a new NULL specification for an Association.

containsAll

public static <T> ContainsAllSpecification<T> containsAll(Property<? extends java.util.Collection<T>> collectionProperty,
                                                          java.lang.Iterable<T> values)
Create a new CONTAINS ALL specification for a Collection Property.

Parameters:
collectionProperty - a Collection Property
values - its values
Returns:
a new CONTAINS ALL specification for a Collection Property.

containsAllVariables

public static <T> ContainsAllSpecification<T> containsAllVariables(Property<? extends java.util.Collection<T>> collectionProperty,
                                                                   java.lang.Iterable<Variable> variables)
Create a new CONTAINS ALL specification for a Collection Property using named Variables.

Parameters:
collectionProperty - a Collection Property
variables - named Variables
Returns:
a new CONTAINS ALL specification for a Collection Property using named Variables.

contains

public static <T> ContainsSpecification<T> contains(Property<? extends java.util.Collection<T>> collectionProperty,
                                                    T value)
Create a new CONTAINS specification for a Collection Property.

Parameters:
collectionProperty - a Collection Property
value - the value
Returns:
a new CONTAINS specification for a Collection Property.

contains

public static <T> ContainsSpecification<T> contains(Property<? extends java.util.Collection<T>> collectionProperty,
                                                    Variable variable)
Create a new CONTAINS specification for a Collection Property using named Variables.

Parameters:
collectionProperty - a Collection Property
variable - named Variable
Returns:
a new CONTAINS specification for a Collection Property using named Variables.

contains

public static <T> ManyAssociationContainsSpecification<T> contains(ManyAssociation<T> manyAssoc,
                                                                   T value)
Create a new CONTAINS specification for a ManyAssociation.

Parameters:
manyAssoc - a ManyAssociation
value - the value
Returns:
a new CONTAINS specification for a ManyAssociation.

orderBy

public static <T> OrderBy orderBy(Property<T> property)
Create a new Query ascending order segment for a Property.

Type Parameters:
T - type of the Property
Parameters:
property - a Property
Returns:
a new Query ascending order segment for a Property.

orderBy

public static <T> OrderBy orderBy(Property<T> property,
                                  OrderBy.Order order)
Create a new Query ordering segment for a Property.

Type Parameters:
T - type of the Property
Parameters:
property - a Property
order - ascending or descending
Returns:
a new Query ordering segment for a Property.