Package host.anzo.commons.collection
Class ListSplitter<T>
java.lang.Object
host.anzo.commons.collection.ListSplitter<T>
- Type Parameters:
T- the type of elements in the collection
A utility class that splits a collection into smaller chunks of a specified size.
-
Constructor Summary
ConstructorsConstructorDescriptionListSplitter(Collection<T> collection, int splitCount) Constructs a ListSplitter with the specified collection and split count. -
Method Summary
Modifier and TypeMethodDescriptiongetNext()Retrieves the next chunk of elements based on the current split count.getNext(int splitCount) Retrieves the next chunk of elements with the specified split count.booleanhasNext()Checks if there are more chunks available to retrieve.booleanisFirst()Checks if the current chunk is the first chunk.booleanisLast()Checks if the current chunk is the last chunk.intsize()Returns the total number of elements in the original collection.
-
Constructor Details
-
ListSplitter
Constructs a ListSplitter with the specified collection and split count.- Parameters:
collection- the collection to be splitsplitCount- the maximum size of each chunk
-
-
Method Details
-
getNext
Retrieves the next chunk of elements with the specified split count.- Parameters:
splitCount- the maximum size of the next chunk- Returns:
- a list containing the next chunk of elements
-
getNext
Retrieves the next chunk of elements based on the current split count.- Returns:
- a list containing the next chunk of elements
-
size
public int size()Returns the total number of elements in the original collection.- Returns:
- the size of the collection
-
isFirst
public boolean isFirst()Checks if the current chunk is the first chunk.- Returns:
- true if the current chunk is the first chunk, false otherwise
-
isLast
public boolean isLast()Checks if the current chunk is the last chunk.- Returns:
- true if the current chunk is the last chunk, false otherwise
-
hasNext
public boolean hasNext()Checks if there are more chunks available to retrieve.- Returns:
- true if there are more chunks, false otherwise
-