Class QueryFactory


  • public class QueryFactory
    extends Object

    QueryFactory class.

    Version:
    $Id: $Id
    Author:
    Long Dinh
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Tuple EMPTY_PARAMS
      Constant EMPTY_PARAMS
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <O> Query<O> all()
      Creates a query which matches all objects in the collection.
      This is equivalent to a literal boolean 'true'.
      static <E> And<E> and​(Query<E> query1, Query<E> query2)
      Creates an And query, representing a logical AND on child queries, which when evaluated yields the set intersection of the result sets from child queries.
      static <E> And<E> and​(Query<E> query1, Query<E> query2, Query<E>... additionalQueries)
      Creates an And query, representing a logical AND on child queries, which when evaluated yields the set intersection of the result sets from child queries.
      static <E> And<E> and​(Query<E> query1, Query<E> query2, Collection<Query<E>> additionalQueries)
      Creates an And query, representing a logical AND on child queries, which when evaluated yields the set intersection of the result sets from child queries.
      static <O> Order<O> ascending​(String fieldName)
      ascending.
      static <O,​A extends Comparable<A>>
      Between<O,​A>
      between​(String fieldName, A lowerValue, A upperValue)
      Creates a Between query which asserts that an attribute is between a lower and an upper bound, inclusive.
      static <O> Like<O> contains​(String fieldName, String value)
      Creates a Like query which asserts that an attribute contains with a certain string fragment.
      static <O> Order<O> descending​(String fieldName)
      descending.
      static Tuple emptyParams()
      emptyParams.
      static <E> Query<E> emptyQuery()
      emptyQuery.
      static <O> Like<O> endsWith​(String fieldName, String value)
      Creates a Like query which asserts that an attribute ends with a certain string fragment.
      static <E> Equal<E> equal​(String fieldName, Object value)
      equal.
      static <O,​A extends Comparable<A>>
      GreaterThan<O,​A>
      greaterThan​(String fieldName, A value)
      Creates a LessThan query which asserts that an attribute is greater than (but not equal to) a lower bound (i.e.
      static <O,​A extends Comparable<A>>
      GreaterThanEqual<O,​A>
      greaterThanOrEqualTo​(String fieldName, A value)
      Creates a GreaterThan query which asserts that an attribute is greater than or equal to a lower bound (i.e.
      static <O> Has<O> has​(String fieldName)
      has.
      static <O> ILike<O> ilike​(String fieldName, String value)
      Creates a ILike query which asserts that an attribute contains with a certain string fragment.
      static <O,​A>
      Query<O>
      in​(String attribute, A... attributeValues)
      Creates a In query which asserts that an attribute has at least one value matching any value in a set of values.
      static <O,​A>
      Query<O>
      in​(String attribute, List<A> attributeValues)
      Creates a In query which asserts that an attribute has at least one value matching any value in a set of values.
      static <O> Query<O> isContainedIn​(String fieldName, String value)
      Creates a Query query which asserts that an attribute is contained in a certain string fragment.
      static <O> IsNull<O> isNull​(String fieldName)
      isNull.
      static <O,​A extends Comparable<A>>
      LessThan<O,​A>
      lessThan​(String fieldName, A value)
      Creates a LessThan query which asserts that an attribute is less than (but not equal to) an upper bound (i.e.
      static <O,​A extends Comparable<A>>
      LessThanEqual<O,​A>
      lessThanOrEqualTo​(String fieldName, A value)
      Creates a LessThanEqual query which asserts that an attribute is less than or equal to an upper bound (i.e.
      static <O> Like<O> like​(String fieldName, String value)
      Creates a Like query which asserts that an attribute contains with a certain string fragment.
      static <O> Query<O> none()
      Creates a query which matches no objects in the collection.
      This is equivalent to a literal boolean 'false'.
      static <O> Not<O> not​(Query<O> query)
      Creates a Not query, representing a logical negation of a child query, which when evaluated yields the set complement of the result set from the child query.
      static <E> NotEqual<E> notEqual​(String fieldName, Object value)
      notEqual.
      static <O> Or<O> or​(Query<O> query1, Query<O> query2)
      Creates an Or query, representing a logical OR on child queries, which when evaluated yields the set union of the result sets from child queries.
      static <O> Or<O> or​(Query<O> query1, Query<O> query2, Query<O>... additionalQueries)
      Creates an Or query, representing a logical OR on child queries, which when evaluated yields the set union of the result sets from child queries.
      static <O> Or<O> or​(Query<O> query1, Query<O> query2, Collection<Query<O>> additionalQueries)
      Creates an Or query, representing a logical OR on child queries, which when evaluated yields the set union of the result sets from child queries.
      static <O> RawQuery<O> raw​(String querySql)
      raw.
      static <O> RawQuery<O> raw​(String querySql, Object... params)
      raw.
      static <O> Like<O> startsWith​(String fieldName, String value)
      Creates a Like query which asserts that an attribute starts with a certain string fragment.
    • Field Detail

      • EMPTY_PARAMS

        public static final Tuple EMPTY_PARAMS
        Constant EMPTY_PARAMS
    • Constructor Detail

      • QueryFactory

        public QueryFactory()
    • Method Detail

      • equal

        public static <E> Equal<E> equal​(String fieldName,
                                         Object value)

        equal.

        Type Parameters:
        E - a E object.
        Parameters:
        fieldName - a String object.
        value - a Object object.
        Returns:
        a Equal object.
      • notEqual

        public static <E> NotEqual<E> notEqual​(String fieldName,
                                               Object value)

        notEqual.

        Type Parameters:
        E - a E object.
        Parameters:
        fieldName - a String object.
        value - a Object object.
        Returns:
        a NotEqual object.
      • lessThanOrEqualTo

        public static <O,​A extends Comparable<A>> LessThanEqual<O,​A> lessThanOrEqualTo​(String fieldName,
                                                                                                   A value)
        Creates a LessThanEqual query which asserts that an attribute is less than or equal to an upper bound (i.e. less than, inclusive).
        Type Parameters:
        O - The type of the object containing the attribute
        A - The type of attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The upper bound to be asserted by the query
        Returns:
        A LessThan query
      • lessThan

        public static <O,​A extends Comparable<A>> LessThan<O,​A> lessThan​(String fieldName,
                                                                                     A value)
        Creates a LessThan query which asserts that an attribute is less than (but not equal to) an upper bound (i.e. less than, exclusive).
        Type Parameters:
        O - The type of the object containing the attribute
        A - The type of attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The upper bound to be asserted by the query
        Returns:
        A LessThan query
      • greaterThanOrEqualTo

        public static <O,​A extends Comparable<A>> GreaterThanEqual<O,​A> greaterThanOrEqualTo​(String fieldName,
                                                                                                         A value)
        Creates a GreaterThan query which asserts that an attribute is greater than or equal to a lower bound (i.e. greater than, inclusive).
        Type Parameters:
        O - The type of the object containing the attribute
        A - The type of attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The lower bound to be asserted by the query
        Returns:
        A GreaterThan query
      • greaterThan

        public static <O,​A extends Comparable<A>> GreaterThan<O,​A> greaterThan​(String fieldName,
                                                                                           A value)
        Creates a LessThan query which asserts that an attribute is greater than (but not equal to) a lower bound (i.e. greater than, exclusive).
        Type Parameters:
        O - The type of the object containing the attribute
        A - The type of attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The lower bound to be asserted by the query
        Returns:
        A GreaterThan query
      • and

        public static <E> And<E> and​(Query<E> query1,
                                     Query<E> query2)
        Creates an And query, representing a logical AND on child queries, which when evaluated yields the set intersection of the result sets from child queries.
        Type Parameters:
        E - The type of the object containing attributes to which child queries refer
        Parameters:
        query1 - The first child query to be connected via a logical AND
        query2 - The second child query to be connected via a logical AND
        Returns:
        An And query, representing a logical AND on child queries
      • and

        public static <E> And<E> and​(Query<E> query1,
                                     Query<E> query2,
                                     Query<E>... additionalQueries)
        Creates an And query, representing a logical AND on child queries, which when evaluated yields the set intersection of the result sets from child queries.
        Type Parameters:
        E - The type of the object containing attributes to which child queries refer
        Parameters:
        query1 - The first child query to be connected via a logical AND
        query2 - The second child query to be connected via a logical AND
        additionalQueries - Additional child queries to be connected via a logical AND
        Returns:
        An And query, representing a logical AND on child queries
      • and

        public static <E> And<E> and​(Query<E> query1,
                                     Query<E> query2,
                                     Collection<Query<E>> additionalQueries)
        Creates an And query, representing a logical AND on child queries, which when evaluated yields the set intersection of the result sets from child queries.
        Type Parameters:
        E - The type of the object containing attributes to which child queries refer
        Parameters:
        query1 - The first child query to be connected via a logical AND
        query2 - The second child query to be connected via a logical AND
        additionalQueries - Additional child queries to be connected via a logical AND
        Returns:
        An And query, representing a logical AND on child queries
      • or

        public static <O> Or<O> or​(Query<O> query1,
                                   Query<O> query2)
        Creates an Or query, representing a logical OR on child queries, which when evaluated yields the set union of the result sets from child queries.
        Type Parameters:
        O - The type of the object containing attributes to which child queries refer
        Parameters:
        query1 - The first child query to be connected via a logical OR
        query2 - The second child query to be connected via a logical OR
        Returns:
        An Or query, representing a logical OR on child queries
      • or

        public static <O> Or<O> or​(Query<O> query1,
                                   Query<O> query2,
                                   Query<O>... additionalQueries)
        Creates an Or query, representing a logical OR on child queries, which when evaluated yields the set union of the result sets from child queries.
        Type Parameters:
        O - The type of the object containing attributes to which child queries refer
        Parameters:
        query1 - The first child query to be connected via a logical OR
        query2 - The second child query to be connected via a logical OR
        additionalQueries - Additional child queries to be connected via a logical OR
        Returns:
        An Or query, representing a logical OR on child queries
      • or

        public static <O> Or<O> or​(Query<O> query1,
                                   Query<O> query2,
                                   Collection<Query<O>> additionalQueries)
        Creates an Or query, representing a logical OR on child queries, which when evaluated yields the set union of the result sets from child queries.
        Type Parameters:
        O - The type of the object containing attributes to which child queries refer
        Parameters:
        query1 - The first child query to be connected via a logical OR
        query2 - The second child query to be connected via a logical OR
        additionalQueries - Additional child queries to be connected via a logical OR
        Returns:
        An Or query, representing a logical OR on child queries
      • not

        public static <O> Not<O> not​(Query<O> query)
        Creates a Not query, representing a logical negation of a child query, which when evaluated yields the set complement of the result set from the child query.
        Type Parameters:
        O - The type of the object containing attributes to which child queries refer
        Parameters:
        query - The child query to be logically negated
        Returns:
        A Not query, representing a logical negation of a child query
      • has

        public static <O> Has<O> has​(String fieldName)

        has.

        Type Parameters:
        O - a O object.
        Parameters:
        fieldName - a String object.
        Returns:
        a Has object.
      • isNull

        public static <O> IsNull<O> isNull​(String fieldName)

        isNull.

        Type Parameters:
        O - a O object.
        Parameters:
        fieldName - a String object.
        Returns:
        a IsNull object.
      • raw

        public static <O> RawQuery<O> raw​(String querySql,
                                          Object... params)

        raw.

        Type Parameters:
        O - a O object.
        Parameters:
        querySql - a String object.
        params - a Object object.
        Returns:
        a RawQuery object.
      • raw

        public static <O> RawQuery<O> raw​(String querySql)

        raw.

        Type Parameters:
        O - a O object.
        Parameters:
        querySql - a String object.
        Returns:
        a RawQuery object.
      • ascending

        public static <O> Order<O> ascending​(String fieldName)

        ascending.

        Type Parameters:
        O - a O object.
        Parameters:
        fieldName - a String object.
        Returns:
        a Order object.
      • descending

        public static <O> Order<O> descending​(String fieldName)

        descending.

        Type Parameters:
        O - a O object.
        Parameters:
        fieldName - a String object.
        Returns:
        a Order object.
      • in

        public static <O,​A> Query<O> in​(String attribute,
                                              A... attributeValues)

        Creates a In query which asserts that an attribute has at least one value matching any value in a set of values.

        Type Parameters:
        A - The type of the attribute
        O - The type of the object containing the attribute
        Parameters:
        attribute - The attribute to which the query refers
        attributeValues - The set of values to match
        Returns:
        An In query
      • in

        public static <O,​A> Query<O> in​(String attribute,
                                              List<A> attributeValues)

        Creates a In query which asserts that an attribute has at least one value matching any value in a set of values.

        Type Parameters:
        A - The type of the attribute
        O - The type of the object containing the attribute
        Parameters:
        attribute - The attribute to which the query refers
        attributeValues - TThe set of values to match
        Returns:
        An In query
      • none

        public static <O> Query<O> none()
        Creates a query which matches no objects in the collection.
        This is equivalent to a literal boolean 'false'.
        Type Parameters:
        O - The type of the objects in the collection
        Returns:
        A query which matches no objects in the collection
      • all

        public static <O> Query<O> all()
        Creates a query which matches all objects in the collection.
        This is equivalent to a literal boolean 'true'.
        Type Parameters:
        O - The type of the objects in the collection
        Returns:
        A query which matches all objects in the collection
      • startsWith

        public static <O> Like<O> startsWith​(String fieldName,
                                             String value)
        Creates a Like query which asserts that an attribute starts with a certain string fragment.
        Type Parameters:
        O - The type of the object containing the attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The value to be asserted by the query
        Returns:
        An Like query
      • endsWith

        public static <O> Like<O> endsWith​(String fieldName,
                                           String value)
        Creates a Like query which asserts that an attribute ends with a certain string fragment.
        Type Parameters:
        O - The type of the object containing the attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The value to be asserted by the query
        Returns:
        An Like query
      • contains

        public static <O> Like<O> contains​(String fieldName,
                                           String value)
        Creates a Like query which asserts that an attribute contains with a certain string fragment.
        Type Parameters:
        O - The type of the object containing the attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The value to be asserted by the query
        Returns:
        An Like query
      • like

        public static <O> Like<O> like​(String fieldName,
                                       String value)
        Creates a Like query which asserts that an attribute contains with a certain string fragment.
        Type Parameters:
        O - The type of the object containing the attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The value to be asserted by the query
        Returns:
        An Like query
      • ilike

        public static <O> ILike<O> ilike​(String fieldName,
                                         String value)
        Creates a ILike query which asserts that an attribute contains with a certain string fragment.
        Type Parameters:
        O - The type of the object containing the attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The value to be asserted by the query
        Returns:
        An ILike query
      • isContainedIn

        public static <O> Query<O> isContainedIn​(String fieldName,
                                                 String value)
        Creates a Query query which asserts that an attribute is contained in a certain string fragment.
        Type Parameters:
        O - The type of the object containing the attribute
        Parameters:
        fieldName - The attribute to which the query refers
        value - The value to be asserted by the query
        Returns:
        An Query query
      • between

        public static <O,​A extends Comparable<A>> Between<O,​A> between​(String fieldName,
                                                                                   A lowerValue,
                                                                                   A upperValue)
        Creates a Between query which asserts that an attribute is between a lower and an upper bound, inclusive.
        Type Parameters:
        O - The type of the object containing the attribute
        A - The type of attribute
        Parameters:
        fieldName - The attribute to which the query refers
        lowerValue - The lower bound to be asserted by the query
        upperValue - The upper bound to be asserted by the query
        Returns:
        A GreaterThan query
      • emptyParams

        public static Tuple emptyParams()

        emptyParams.

        Returns:
        a Tuple object.
      • emptyQuery

        public static <E> Query<E> emptyQuery()

        emptyQuery.

        Type Parameters:
        E - a E object.
        Returns:
        a Query object.