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 int
getNextStartIndex()
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 returnedint
getNiceEndIndex()
Returns an end index for use in the UI.int
getNiceStartIndex()
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 sizeint
getPageSize()
Returns the number of items available on the current page.int
getPreviousStartIndex()
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 returnedint
getStartIndex()
Returns the start index.int
getStartIndexValue()
Always return the start index value, regardless of whether the pagination has any total.int
getTotal()
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:PaginationSupport
Returns an end index for use in the UI. It returns the end index - 1- Specified by:
getNiceEndIndex
in interfacePaginationSupport<T>
- Returns:
- a nice end index
-
getStartIndex
public int getStartIndex()
Description copied from interface:PaginationSupport
Returns 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:
getStartIndex
in interfacePaginationSupport<T>
- Returns:
- the start index.
-
getStartIndexValue
public int getStartIndexValue()
Description copied from interface:PaginationSupport
Always return the start index value, regardless of whether the pagination has any total.- Specified by:
getStartIndexValue
in 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:
getNextStartIndex
in 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:
getPreviousStartIndex
in 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:PaginationSupport
Returns an array of start indexes for pages that appear after the current page If there are no further pages, null is returned- Specified by:
getNextStartIndexes
in interfacePaginationSupport<T>
- Returns:
- an array of start indexes for pages that appear after the current page
-
getPreviousStartIndexes
public int[] getPreviousStartIndexes()
Description copied from interface:PaginationSupport
Returns an array of start indexes for pages that appear before the current page If there are no preceding pages, null is returned- Specified by:
getPreviousStartIndexes
in interfacePaginationSupport<T>
- Returns:
- an array of start indexes for pages that appear before the current page
-
getNiceStartIndex
public int getNiceStartIndex()
Description copied from interface:PaginationSupport
Returns a start index for use in the UI. It returns the start index + 1- Specified by:
getNiceStartIndex
in 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:
getPage
in 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:PaginationSupport
Returns the total number of items in the list- Specified by:
getTotal
in interfacePaginationSupport<T>
- Returns:
- total number of items in the list
-
getPageSize
public int getPageSize()
Description copied from interface:PaginationSupport
Returns the number of items available on the current page.- Specified by:
getPageSize
in interfacePaginationSupport<T>
- Returns:
- the number of items available on the current page.
-
-