Class JqlQueryBuilder

java.lang.Object
com.atlassian.jira.jql.builder.JqlQueryBuilder

@NotThreadSafe public class JqlQueryBuilder extends Object
Used to build Query's that can be used to perform issue searching in JIRA.

This gives you access to a JqlClauseBuilder which can be used to build up the where clause of the JQL and also a JqlOrderByBuilder which can be used to build up the order by clause of the JQL.

This object can also be used as a factory for JqlClauseBuilder and JqlOrderByBuilder instances.

Note that the results of an empty query may vary depending on

invalid reference
com.atlassian.jira.config.properties.APKeys.JIRA_EMPTY_JQL_RETURNS_NO_DATA_ENABLED
application property flag. If this flag is set to true, then no result will be returned instead of returning all existing items.
Since:
v4.0
See Also:
  • Method Details

    • newBuilder

      @Nonnull public static JqlQueryBuilder newBuilder()
      Returns:
      a new builder that can be used to build a JQL query.
    • newBuilder

      @Nonnull public static JqlQueryBuilder newBuilder(Query existingQuery)
      Creates a new builder that clones the state of the passed in query so that you can use the resulting builder to create a slightly modified query.
      Parameters:
      existingQuery - the template to clone, both the where clause and order by clause will be cloned.
      Returns:
      a new builder that clones the state of the passed in query.
    • newClauseBuilder

      @Nonnull public static JqlClauseBuilder newClauseBuilder()
      Build a new JqlClauseBuilder. The returned builder will have no associated JqlQueryBuilder.
      Returns:
      the new clause builder.
    • newClauseBuilder

      @Nonnull public static JqlClauseBuilder newClauseBuilder(Clause copy)
      Build a new JqlClauseBuilder and initialise it with the passed clause. The returned builder will have no associated JqlQueryBuilder.
      Parameters:
      copy - the claue to add to the new builder. Can be null.
      Returns:
      the new clause builder.
    • newClauseBuilder

      @Nonnull public static JqlClauseBuilder newClauseBuilder(Query query)
      Build a new JqlClauseBuilder and initialise it with the clause from the passed query. The returned builder will have no associated JqlQueryBuilder.
      Parameters:
      query - the query whose where clause will be copied into the new builder. Can be null.
      Returns:
      the new clause builder.
    • newOrderByBuilder

      @Nonnull public static JqlOrderByBuilder newOrderByBuilder()
      Build a new JqlOrderByBuilder. The returned builder will have no associated JqlQueryBuilder.
      Returns:
      the new clause builder.
    • newOrderByBuilder

      @Nonnull public static JqlOrderByBuilder newOrderByBuilder(OrderBy copy)
      Build a new JqlOrderByBuilder and initialise it with the passed order. The returned builder will have no associated JqlQueryBuilder.
      Parameters:
      copy - the order to copy. Can be null.
      Returns:
      the new clause builder.
    • newOrderByBuilder

      @Nonnull public static JqlOrderByBuilder newOrderByBuilder(Query query)
      Build a new JqlOrderByBuilder and initialise it with the order from the passed query. The returned builder will have no associated JqlQueryBuilder.
      Parameters:
      query - the query whose order will be copied into the new builder. Can be null.
      Returns:
      the new clause builder.
    • orderBy

      @Nonnull public JqlOrderByBuilder orderBy()
      Creates an JqlOrderByBuilder that can be used to modify the order by statements of the JqlQueryBuilder instance.
      Returns:
      an OrderBy builder associated with the JqlQueryBuilder instance.
    • where

      @Nonnull public JqlClauseBuilder where()
      Creates an JqlClauseBuilder which is used to modify the where clause portion of the JqlQueryBuilder instance.
      Returns:
      a WhereClause builder associated with the JqlQueryBuilder instance.
    • buildQuery

      @Nonnull public Query buildQuery()
      This will find the root of the clause tree and build a Query whos where clause will return the generated clause and Order By clause will return the generated search order.

      NOTE: Calling this method does not change the state of the builder, there are no limitations on the number of times this method can be invoked.

      Returns:
      a Query whos where clause contains the built clauses and search order contains the built OrderBy clauses.
    • clear

      public JqlQueryBuilder clear()
      Reset the builder to its empty state.
      Returns:
      this builder with its state cleared.