Class DefaultListBuilder<T>

java.lang.Object
com.atlassian.confluence.core.DefaultListBuilder<T>
All Implemented Interfaces:
ListBuilder<T>, Iterable<List<T>>

public class DefaultListBuilder<T> extends Object implements ListBuilder<T>
Skeleton implementation of a list builder that takes care of maintaining the class invariants but delegates the final building of the list to a callback function.
  • Method Details

    • newInstance

      public static <T> DefaultListBuilder<T> newInstance(ListBuilderCallback<T> callback)
      Instantiate a new default ListBuilder from a callback. We use a factory method so we can take advantage of type inference.
      Parameters:
      callback - the callback from which the builder should retrieve data
      Returns:
      the appropriate list builder.
    • getRange

      public List<T> getRange(int startIndex, int endIndex)
      Description copied from interface: ListBuilder
      Gets a range of results by providing the indexes of the first and last elements you wish to return. This is an inclusive range. Requesting a range that falls outside the list of available elements will result in a short, or empty list.
      Specified by:
      getRange in interface ListBuilder<T>
      Parameters:
      startIndex - the zero-based index of the first result you wish returned
      endIndex - the zero-based index of the last result you wish returned
      Returns:
      the list of available results in that range, or an empty list if no results are within the range
    • getPage

      public List<T> getPage(int offset, int maxResults)
      Description copied from interface: ListBuilder
      Gets a page of results by providing the offset of the first element in the page, and the page size. Requesting a page that falls outside the list of available elements will result in a short, or empty list.
      Specified by:
      getPage in interface ListBuilder<T>
      Parameters:
      offset - the zero-based index of the first result you wish returned
      maxResults - the size of the page requested
      Returns:
      the list of available results in that range, or an empty list if no results are within the range
    • iterator

      public Iterator<List<T>> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • getAvailableSize

      public int getAvailableSize()
      Description copied from interface: ListBuilder
      Gets the total number of elements available to return if the whole list were requested
      Specified by:
      getAvailableSize in interface ListBuilder<T>
      Returns:
      the total number of list elements available