Class CmsListSplitter<T extends I_CmsHasSize>

java.lang.Object
org.opencms.gwt.client.util.CmsListSplitter<T>
Type Parameters:
T - the type of items in the list to be partitioned

public class CmsListSplitter<T extends I_CmsHasSize> extends 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 Details

    • CmsListSplitter

      public CmsListSplitter(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 Details

    • getMore

      public List<T> getMore()
      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