Class QueryUtils

java.lang.Object
com.commercetools.api.client.QueryUtils

public class QueryUtils extends Object
  • Constructor Details

    • QueryUtils

      public QueryUtils()
  • Method Details

    • queryAll

      @Nonnull public static <TMethod extends SimplePagedQueryResourceRequest<TMethod, TResult, ?>, TResult extends ResourcePagedQueryResponse<TElement>, TElement extends DomainResource<TElement>, S> CompletionStage<List<S>> queryAll(@Nonnull SimplePagedQueryResourceRequest<TMethod,TResult,?> query, @Nonnull Function<List<TElement>,S> pageMapper)

      Queries all elements matching a query by using a limit based pagination with a combination of id sorting and a page size 500. More on the algorithm can be found here: Iterating all elements.

      The method takes a callback Function that returns a result of type <S> that is returned on every page of elements queried. Eventually, the method returns a CompletionStage that contains a list of all the results of the callbacks returned from every page.

      NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.

      Type Parameters:
      TElement - type of one query result element
      TMethod - type of the query
      TResult - type of the result
      S - type of the returned result of the callback function on every page.
      Parameters:
      query - query containing predicates and expansion paths
      pageMapper - callback function that is called on every page queried
      Returns:
      a completion stage containing a list of mapped pages as a result.
    • queryAll

      @Nonnull public static <TMethod extends SimplePagedQueryResourceRequest<TMethod, TResult, ?>, TResult extends ResourcePagedQueryResponse<TElement>, TElement extends DomainResource<TElement>> CompletionStage<Void> queryAll(@Nonnull SimplePagedQueryResourceRequest<TMethod,TResult,?> query, @Nonnull Consumer<List<TElement>> pageConsumer)

      Queries all elements matching a query by using a limit based pagination with a combination of id sorting and a page size 500. More on the algorithm can be found here: Iterating all elements.

      The method takes a consumer Consumer that is applied on every page of elements queried.

      NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.

      Type Parameters:
      TElement - type of one query result element
      TMethod - type of the query
      TResult - type of the result
      Parameters:
      query - query containing predicates and expansion paths
      pageConsumer - consumer applied on every page queried
      Returns:
      a completion stage containing void as a result after the consumer was applied on all pages.
    • queryAll

      @Nonnull public static <TMethod extends SimplePagedQueryResourceRequest<TMethod, TResult, ?>, TResult extends ResourcePagedQueryResponse<TElement>, TElement extends DomainResource<TElement>, S> CompletionStage<List<S>> queryAll(@Nonnull SimplePagedQueryResourceRequest<TMethod,TResult,?> query, @Nonnull Function<List<TElement>,S> pageMapper, int pageSize)

      Queries all elements matching a query by using a limit based pagination with a combination of id sorting and the supplied pageSize. More on the algorithm can be found here: Iterating all elements.

      The method takes a callback Function that returns a result of type <S> that is returned on every page of elements queried. Eventually, the method returns a CompletionStage that contains a list of all the results of the callbacks returned from every page.

      NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.

      Type Parameters:
      TElement - type of one query result element
      TMethod - type of the query
      TResult - type of the result
      S - type of the returned result of the callback function on every page.
      Parameters:
      query - query containing predicates and expansion paths
      pageMapper - callback function that is called on every page queried
      pageSize - the page size.
      Returns:
      a completion stage containing a list of mapped pages as a result.
    • queryAll

      @Nonnull public static <TMethod extends SimplePagedQueryResourceRequest<TMethod, TResult, ?>, TResult extends ResourcePagedQueryResponse<TElement>, TElement extends DomainResource<TElement>> CompletionStage<Void> queryAll(@Nonnull SimplePagedQueryResourceRequest<TMethod,TResult,?> query, @Nonnull Consumer<List<TElement>> pageConsumer, int pageSize)

      Queries all elements matching a query by using a limit based pagination with a combination of id sorting and the supplied pageSize. More on the algorithm can be found here: Iterating all elements.

      The method takes a Consumer that is applied on every page of the queried elements.

      NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.

      Type Parameters:
      TElement - type of one query result element
      TMethod - type of the query
      TResult - type of the result
      Parameters:
      query - query containing predicates and expansion paths
      pageConsumer - consumer applied on every page queried
      pageSize - the page size
      Returns:
      a completion stage containing void as a result after the consumer was applied on all pages.