Class ChunkUtils


  • public class ChunkUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ChunkUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.List<java.util.List<T>> chunk​(java.util.Collection<T> elements, int chunkSize)
      Given a collection of items and a chunkSize, this method chunks the elements into chunks with the chunkSize represented by a List of elements.
      static java.util.concurrent.CompletableFuture<java.util.List<io.vrap.rmf.base.client.ApiHttpResponse<com.commercetools.api.models.graph_ql.GraphQLResponse>>> executeChunks​(com.commercetools.api.client.ProjectApiRoot ctpClient, java.util.List<com.commercetools.api.models.graph_ql.GraphQLRequest> requests)
      Executes the given List of GraphQLRequests, and collects results in a list.
      static <ResourceT extends com.commercetools.api.client.PagedQueryResourceRequest<ResourceT,​ResultT,​QueryBuilderDslT>,​ResultT,​QueryBuilderDslT>
      java.util.concurrent.CompletableFuture<java.util.List<io.vrap.rmf.base.client.ApiHttpResponse<ResultT>>>
      executeChunks​(java.util.List<ResourceT> requests)
      Executes the given List of PagedQueryResourceRequests, and collects results in a list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChunkUtils

        public ChunkUtils()
    • Method Detail

      • executeChunks

        public static <ResourceT extends com.commercetools.api.client.PagedQueryResourceRequest<ResourceT,​ResultT,​QueryBuilderDslT>,​ResultT,​QueryBuilderDslT> java.util.concurrent.CompletableFuture<java.util.List<io.vrap.rmf.base.client.ApiHttpResponse<ResultT>>> executeChunks​(@Nonnull
                                                                                                                                                                                                                                                                                                             java.util.List<ResourceT> requests)
        Executes the given List of PagedQueryResourceRequests, and collects results in a list.
        Type Parameters:
        ResourceT - the type of the request model.
        ResultT - the type of the underlying model.
        QueryBuilderDslT - the type of the query builder dsl class (e.g. CartDiscountQueryBuilderDsl, CustomerQueryBuilderDsl, ...).
        Parameters:
        requests - A list of PagedQueryResourceRequest implementation to allow ProjectApiRoot to execute queries on CTP.
        Returns:
        a list of lists where each list represents the results of passed PagedQueryResourceRequest.
      • executeChunks

        public static java.util.concurrent.CompletableFuture<java.util.List<io.vrap.rmf.base.client.ApiHttpResponse<com.commercetools.api.models.graph_ql.GraphQLResponse>>> executeChunks​(@Nonnull
                                                                                                                                                                                           com.commercetools.api.client.ProjectApiRoot ctpClient,
                                                                                                                                                                                           @Nonnull
                                                                                                                                                                                           java.util.List<com.commercetools.api.models.graph_ql.GraphQLRequest> requests)
        Executes the given List of GraphQLRequests, and collects results in a list.
        Parameters:
        requests - A list of GraphQLRequest implementation to allow ProjectApiRoot to execute queries on CTP.
        Returns:
        a list of lists where each list represents the results of passed GraphQLRequest.
      • chunk

        public static <T> java.util.List<java.util.List<T>> chunk​(@Nonnull
                                                                  java.util.Collection<T> elements,
                                                                  int chunkSize)
        Given a collection of items and a chunkSize, this method chunks the elements into chunks with the chunkSize represented by a List of elements.
        Type Parameters:
        T - the type of the underlying model.
        Parameters:
        elements - the list of elements
        chunkSize - the size of each chunk.
        Returns:
        a list of lists where each list represents a chunk of elements.