public class ChunkUtils
extends java.lang.Object
Constructor and Description |
---|
ChunkUtils() |
Modifier and Type | Method and 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 <T,Q extends io.sphere.sdk.client.SphereRequest<T>> |
executeChunks(io.sphere.sdk.client.SphereClient client,
java.util.List<Q> requests)
Executes the given
List of SphereRequest s, and collects results in a list. |
static <T extends GraphQlBaseResult<U>,U extends GraphQlBaseResource> |
flattenGraphQLBaseResults(java.util.List<T> graphQlBaseResults)
Flat map the list of lists of
GraphQlBaseResult to the set of U . |
static <T> java.util.List<T> |
flattenPagedQueryResults(java.util.List<io.sphere.sdk.queries.PagedQueryResult<T>> pagedQueryResults)
Flat map the list of lists of
PagedQueryResult to the list of T . |
public static <T,Q extends io.sphere.sdk.client.SphereRequest<T>> java.util.concurrent.CompletableFuture<java.util.List<T>> executeChunks(@Nonnull io.sphere.sdk.client.SphereClient client, @Nonnull java.util.List<Q> requests)
List
of SphereRequest
s, and collects results in a list.T
- the type of the underlying model.Q
- the type of the request model.client
- SphereClient
responsible for interaction with the target CTP project.requests
- A list of SphereRequest
implementation to allow SphereClient
to
execute queries on CTP.SphereRequest
.public static <T> java.util.List<T> flattenPagedQueryResults(@Nonnull java.util.List<io.sphere.sdk.queries.PagedQueryResult<T>> pagedQueryResults)
PagedQueryResult
to the list of T
.T
- the type of the underlying model.pagedQueryResults
- query responses which contains a subset of the matching values.T
public static <T extends GraphQlBaseResult<U>,U extends GraphQlBaseResource> java.util.Set<U> flattenGraphQLBaseResults(@Nonnull java.util.List<T> graphQlBaseResults)
GraphQlBaseResult
to the set of U
.U
- the type of the resource model.T
- the type of the generic result type.graphQlBaseResults
- query responses which contains a subset of the matching values.U
public static <T> java.util.List<java.util.List<T>> chunk(@Nonnull java.util.Collection<T> elements, int chunkSize)
chunkSize
, this method chunks the elements into
chunks with the chunkSize
represented by a List
of elements.T
- the type of the underlying model.elements
- the list of elementschunkSize
- the size of each chunk.