Interface ListBuilder<T>

  • All Superinterfaces:
    Iterable<List<T>>
    All Known Implementing Classes:
    DefaultListBuilder

    public interface ListBuilder<T>
    extends Iterable<List<T>>
    A lazy builder that allows clients to retrieve individual pages of potentially long (and performance-degrading) lists of entities. If a method returns a list builder and you automatically get every possible member of the list, YOU ARE DOING IT WRONG.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getAvailableSize()
      Gets the total number of elements available to return if the whole list were requested
      List<T> getPage​(int offset, int maxResults)
      Gets a page of results by providing the offset of the first element in the page, and the page size.
      List<T> getRange​(int startIndex, int endIndex)
      Gets a range of results by providing the indexes of the first and last elements you wish to return.
    • Method Detail

      • getRange

        List<T> getRange​(int startIndex,
                         int endIndex)
        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.
        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

        List<T> getPage​(int offset,
                        int maxResults)
        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.
        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
      • getAvailableSize

        int getAvailableSize()
        Gets the total number of elements available to return if the whole list were requested
        Returns:
        the total number of list elements available