Class ChunkUtils
- java.lang.Object
-
- com.commercetools.sync.commons.utils.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 achunkSize
, this method chunks the elements into chunks with thechunkSize
represented by aList
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 givenList
ofGraphQLRequest
s, 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 givenList
ofPagedQueryResourceRequest
s, and collects results in a list.
-
-
-
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 givenList
ofPagedQueryResourceRequest
s, 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 ofPagedQueryResourceRequest
implementation to allowProjectApiRoot
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 givenList
ofGraphQLRequest
s, and collects results in a list.- Parameters:
requests
- A list ofGraphQLRequest
implementation to allowProjectApiRoot
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 achunkSize
, this method chunks the elements into chunks with thechunkSize
represented by aList
of elements.- Type Parameters:
T
- the type of the underlying model.- Parameters:
elements
- the list of elementschunkSize
- the size of each chunk.- Returns:
- a list of lists where each list represents a chunk of elements.
-
-