Class ListSplitter<T>

java.lang.Object
host.anzo.commons.collection.ListSplitter<T>
Type Parameters:
T - the type of elements in the collection

public class ListSplitter<T> extends Object
A utility class that splits a collection into smaller chunks of a specified size.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ListSplitter(Collection<T> collection, int splitCount)
    Constructs a ListSplitter with the specified collection and split count.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    boolean
    Checks if there are more chunks available to retrieve.
    boolean
    Checks if the current chunk is the first chunk.
    boolean
    Checks if the current chunk is the last chunk.
    int
    Returns the total number of elements in the original collection.

    Methods inherited from class java.lang.Object

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

    • ListSplitter

      public ListSplitter(Collection<T> collection, int splitCount)
      Constructs a ListSplitter with the specified collection and split count.
      Parameters:
      collection - the collection to be split
      splitCount - the maximum size of each chunk
  • Method Details

    • getNext

      public List<T> getNext(int splitCount)
      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

      public List<T> 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