Class ListBuilderPaginationSupport<T>
- java.lang.Object
-
- com.atlassian.confluence.plugins.spacedirectory.util.ListBuilderPaginationSupport<T>
-
- Type Parameters:
T- - the type of the item
- All Implemented Interfaces:
PaginationSupport<T>
public class ListBuilderPaginationSupport<T> extends Object implements PaginationSupport<T>
Calculates pagination indexes using a com.atlassian.confluence.core.ListBuilder. This is preferable to using bucket.core.actions.PaginationSupport, since it only loads part of the list into memory.
-
-
Constructor Summary
Constructors Constructor Description ListBuilderPaginationSupport(int startIndex, int pageSize, ListBuilder<T> items)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetNextStartIndex()Returns the next start index.int[]getNextStartIndexes()Returns an array of start indexes for pages that appear after the current page If there are no further pages, null is returnedintgetNiceEndIndex()Returns an end index for use in the UI.intgetNiceStartIndex()Returns a start index for use in the UI.List<T>getPage()Returns a subset of the list of items passed in, based on startIndex and the page sizeintgetPageSize()Returns the number of items available on the current page.intgetPreviousStartIndex()Returns the previous start index.int[]getPreviousStartIndexes()Returns an array of start indexes for pages that appear before the current page If there are no preceding pages, null is returnedintgetStartIndex()Returns the start index.intgetStartIndexValue()Always return the start index value, regardless of whether the pagination has any total.intgetTotal()Returns the total number of items in the list
-
-
-
Constructor Detail
-
ListBuilderPaginationSupport
public ListBuilderPaginationSupport(int startIndex, int pageSize, ListBuilder<T> items)
-
-
Method Detail
-
getNiceEndIndex
public int getNiceEndIndex()
Description copied from interface:PaginationSupportReturns an end index for use in the UI. It returns the end index - 1- Specified by:
getNiceEndIndexin interfacePaginationSupport<T>- Returns:
- a nice end index
-
getStartIndex
public int getStartIndex()
Description copied from interface:PaginationSupportReturns the start index. If the start index exceeds the index of the last element, the index of the last element is returned. If the start index is less than 0, 0 is returned.- Specified by:
getStartIndexin interfacePaginationSupport<T>- Returns:
- the start index.
-
getStartIndexValue
public int getStartIndexValue()
Description copied from interface:PaginationSupportAlways return the start index value, regardless of whether the pagination has any total.- Specified by:
getStartIndexValuein interfacePaginationSupport<T>- Returns:
- the start index value, regardless of whether the pagination has any total.
-
getNextStartIndex
public int getNextStartIndex()
Returns the next start index. Returns -1 if we are on the last page (there is no next page).- Specified by:
getNextStartIndexin interfacePaginationSupport<T>- Returns:
- the next start index. Returns -1 if we are on the last page (there is no next page).
-
getPreviousStartIndex
public int getPreviousStartIndex()
Returns the previous start index. Returns -1 if we are on the first page (there is no previous page).- Specified by:
getPreviousStartIndexin interfacePaginationSupport<T>- Returns:
- the previous start index. Returns -1 if we are on the first page (there is no previous page).
-
getNextStartIndexes
public int[] getNextStartIndexes()
Description copied from interface:PaginationSupportReturns an array of start indexes for pages that appear after the current page If there are no further pages, null is returned- Specified by:
getNextStartIndexesin interfacePaginationSupport<T>- Returns:
- an array of start indexes for pages that appear after the current page
-
getPreviousStartIndexes
public int[] getPreviousStartIndexes()
Description copied from interface:PaginationSupportReturns an array of start indexes for pages that appear before the current page If there are no preceding pages, null is returned- Specified by:
getPreviousStartIndexesin interfacePaginationSupport<T>- Returns:
- an array of start indexes for pages that appear before the current page
-
getNiceStartIndex
public int getNiceStartIndex()
Description copied from interface:PaginationSupportReturns a start index for use in the UI. It returns the start index + 1- Specified by:
getNiceStartIndexin interfacePaginationSupport<T>- Returns:
- a nice start index
-
getPage
public List<T> getPage()
Returns a subset of the list of items passed in, based on startIndex and the page size- Specified by:
getPagein interfacePaginationSupport<T>- Returns:
- a subset of the list of items passed in, based on startIndex and the page size
-
getTotal
public int getTotal()
Description copied from interface:PaginationSupportReturns the total number of items in the list- Specified by:
getTotalin interfacePaginationSupport<T>- Returns:
- total number of items in the list
-
getPageSize
public int getPageSize()
Description copied from interface:PaginationSupportReturns the number of items available on the current page.- Specified by:
getPageSizein interfacePaginationSupport<T>- Returns:
- the number of items available on the current page.
-
-