com.atlassian.confluence.core
Interface ListBuilder<T>

All Known Implementing Classes:
DefaultListBuilder

public interface ListBuilder<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
 int getAvailableSize()
          Gets the total number of elements available to return if the whole list were requested
 java.util.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.
 java.util.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

java.util.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

java.util.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


Copyright © 2003-2010 Atlassian. All Rights Reserved.