Class CmsListSplitter<T extends I_CmsHasSize>

  • Type Parameters:
    T - the type of items in the list to be partitioned

    public class CmsListSplitter<T extends I_CmsHasSize>
    extends java.lang.Object
    A utility class for partitioning a list of items (each of which has a given size) into one or more batches of consecutive items such that each batch except the last one consists of just enough items to make the total sum of item sizes in the batch greater or equal than a given parameter.

    Since:
    8.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      CmsListSplitter​(java.util.List<T> items, int batchSize)
      Creates a new instance of a list splitter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<T> getMore()
      Gets the next batch of items.
      boolean hasMore()
      Returns true if there are more items left.
      • Methods inherited from class java.lang.Object

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

      • CmsListSplitter

        public CmsListSplitter​(java.util.List<T> items,
                               int batchSize)
        Creates a new instance of a list splitter.

        Parameters:
        items - the list of items to split
        batchSize - the minimum size of the batches (except for the last batch)
    • Method Detail

      • getMore

        public java.util.List<TgetMore()
        Gets the next batch of items.

        This will fail if there are no more items.

        Returns:
        the next batch of items
      • hasMore

        public boolean hasMore()
        Returns true if there are more items left.

        Returns:
        true if there are more items left