java.lang.Object
org.springframework.data.cassandra.core.query.Query
All Implemented Interfaces:
Iterable<CriteriaDefinition>, Supplier<Stream<CriteriaDefinition>>, Filter, Streamable<CriteriaDefinition>

public class Query extends Object implements Filter
Query object representing CriteriaDefinitions, Columns, Sort, paging state and QueryOptions for a CQL query. Query is created with a fluent API creating immutable objects.
Since:
2.0
Author:
Mark Paluch
See Also:
  • Method Details

    • empty

      public static Query empty()
      Static factory method to create an empty Query.
      Returns:
      a new, empty Query.
    • query

      public static Query query(CriteriaDefinition... criteriaDefinitions)
      Static factory method to create a Query using the provided CriteriaDefinition.
      Parameters:
      criteriaDefinitions - must not be null.
      Returns:
      the Query for CriteriaDefinitions.
    • query

      public static Query query(Iterable<? extends CriteriaDefinition> criteriaDefinitions)
      Static factory method to create a Query using the provided CriteriaDefinition.
      Parameters:
      criteriaDefinitions - must not be null.
      Returns:
      the Query for CriteriaDefinitions.
    • and

      public Query and(CriteriaDefinition criteriaDefinition)
      Add the given CriteriaDefinition to the current Query.
      Parameters:
      criteriaDefinition - must not be null.
      Returns:
      a new Query object containing the former settings with CriteriaDefinition applied.
    • getCriteriaDefinitions

      public Iterable<CriteriaDefinition> getCriteriaDefinitions()
      Specified by:
      getCriteriaDefinitions in interface Filter
      Returns:
      the CriteriaDefinitions.
    • columns

      public Query columns(Columns columns)
      Add Columns to the Query instance. Existing definitions are merged or overwritten for overriding ColumnNames in columns.
      Parameters:
      columns - must not be null.
      Returns:
      a new Query object containing the former settings with Columns applied.
    • getColumns

      public Columns getColumns()
      Returns:
      the query Columns.
    • sort

      public Query sort(Sort sort)
      Add a Sort to the Query instance.
      Parameters:
      sort - must not be null.
      Returns:
      a new Query object containing the former settings with Sort applied.
    • getSort

      public Sort getSort()
      Returns:
      the query Sort object.
    • pageRequest

      public Query pageRequest(Pageable pageable)
      Create a Query initialized with a PageRequest to fetch the first page of results or advance in paging along with sorting. Reads (and overrides, if set) page size into QueryOptions#getPageSize() and sets pagingState and Sort.
      Parameters:
      pageable - must not be null.
      Returns:
      a new Query object containing the former settings with PageRequest applied.
      See Also:
    • pagingState

      public Query pagingState(CassandraScrollPosition scrollPosition)
      Set the paging state to skip rows.
      Parameters:
      scrollPosition - must not be null.
      Returns:
      a new Query object containing the former settings with paging state applied.
    • pagingState

      public Query pagingState(ByteBuffer pagingState)
      Set the paging state to skip rows.
      Parameters:
      pagingState - must not be null.
      Returns:
      a new Query object containing the former settings with paging state applied.
    • getPagingState

      public Optional<ByteBuffer> getPagingState()
      Returns:
      the optional paging state.
    • queryOptions

      public Query queryOptions(QueryOptions queryOptions)
      Set the QueryOptions.
      Parameters:
      queryOptions - must not be null.
      Returns:
      a new Query object containing the former settings with QueryOptions applied.
    • getQueryOptions

      public Optional<QueryOptions> getQueryOptions()
      Returns:
      the optional QueryOptions.
    • limit

      public Query limit(long limit)
      Limit the number of returned rows to limit.
      Parameters:
      limit -
      Returns:
      a new Query object containing the former settings with limit applied.
    • limit

      public Query limit(Limit limit)
      Limit the number of returned rows to Limit.
      Parameters:
      limit -
      Returns:
      a new Query object containing the former settings with limit applied.
    • getLimit

      public long getLimit()
      Returns:
      the maximum number of rows to be returned.
    • isLimited

      public boolean isLimited()
      Returns:
      true if the query is limited.
    • withAllowFiltering

      public Query withAllowFiltering()
      Allow filtering with this Query.
      Returns:
      a new Query object containing the former settings with allowFiltering applied.
    • isAllowFiltering

      public boolean isAllowFiltering()
      Returns:
      true to allow filtering.
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • querySettingsEquals

      protected boolean querySettingsEquals(Query that)
      Tests whether the settings of the given Query are equal to this query.
      Parameters:
      that -
      Returns:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object