Package dev.aurelium.slate.inv.content
Interface Pagination
- All Known Implementing Classes:
Pagination.Impl
public interface Pagination
Pagination system which lets you switch pages;
easily get items in the given page,
easily manipulate the pages and
check if a page is the first or the last one
(isFirst() / isLast()).
You must start by setting the items and the itemsPerPage,
then you can manipulate the pages by using the
page(int) /
first() /
previous() /
next() /
last()
methods.
Then, when you need to get all the items of the current page,
either use the getPageItems() method, or directly
add the items to your inventory with a SlotIterator and the
method addToIterator(SlotIterator)
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionaddToIterator(SlotIterator iterator) Adds all the current page items to the given iterator.first()Sets the current page to the first page.intgetPage()Gets the current page.Gets the items of the current page.booleanisFirst()Checks if the current page is the first page.booleanisLast()Checks if the current page is the last page.last()Sets the current page to the last page.next()Sets the current page to the next page, if the current page is already the last page, this do nothing.page(int page) Sets the current page.previous()Sets the current page to the previous page, if the current page is already the first page, this do nothing.setItems(ClickableItem... items) Sets all the items for this Pagination.setItemsPerPage(int itemsPerPage) Sets the maximum amount of items per page.
-
Method Details
-
getPageItems
ClickableItem[] getPageItems()Gets the items of the current page.
This returns an array of the size of the items per page.- Returns:
- the current page items
-
getPage
int getPage()Gets the current page.- Returns:
- the current page
-
page
Sets the current page.- Parameters:
page- the current page- Returns:
this, for chained calls
-
isFirst
boolean isFirst()Checks if the current page is the first page.
This is equivalent to:page == 0- Returns:
trueif this page is the first page
-
isLast
boolean isLast()Checks if the current page is the last page.
This is equivalent to:page == itemsCount / itemsPerPage- Returns:
trueif this page is the last page
-
first
Pagination first()Sets the current page to the first page.
This is equivalent to:page(0)- Returns:
this, for chained calls
-
previous
Pagination previous()Sets the current page to the previous page, if the current page is already the first page, this do nothing.- Returns:
this, for chained calls
-
next
Pagination next()Sets the current page to the next page, if the current page is already the last page, this do nothing.- Returns:
this, for chained calls
-
last
Pagination last()Sets the current page to the last page.
This is equivalent to:page(itemsCount / itemsPerPage)- Returns:
this, for chained calls
-
addToIterator
Adds all the current page items to the given iterator.- Parameters:
iterator- the iterator- Returns:
this, for chained calls
-
setItems
Sets all the items for this Pagination.- Parameters:
items- the items- Returns:
this, for chained calls
-
setItemsPerPage
Sets the maximum amount of items per page.- Parameters:
itemsPerPage- the maximum amount of items per page- Returns:
this, for chained calls
-