public class Page extends Object
Utility class to represent paging information. Page instances are immutable.
Usage:
Page page = Page.ofSize(25);
Page secondPage = page.next();
| Modifier and Type | Field and Description |
|---|---|
int |
index
The current page index (0-based).
|
int |
size
The current page size;
|
| Constructor and Description |
|---|
Page(int size)
Builds a page of the given size.
|
Page(int index,
int size)
Builds a page of the given index and size.
|
| Modifier and Type | Method and Description |
|---|---|
Page |
first()
Returns a new page with the first page index (0) and the same size, or this page if it is the first page.
|
Page |
index(int newIndex)
Returns a new page at the given page index and the same size, or this page if the page index is the same.
|
Page |
next()
Returns a new page with the next page index and the same size.
|
static Page |
of(int index,
int size)
Builds a page of the given index and size.
|
static Page |
ofSize(int size)
Builds a page of the given size.
|
Page |
previous()
Returns a new page with the previous page index and the same size, or this page if it is the first page.
|
public final int index
public final int size
public Page(int size)
size - the page sizeIllegalArgumentException - if the page size is less than or equal to 0ofSize(int)public Page(int index,
int size)
index - the page index (0-based)size - the page sizeIllegalArgumentException - if the page index is less than 0IllegalArgumentException - if the page size is less than or equal to 0of(int, int)public static Page of(int index, int size)
index - the page index (0-based)size - the page sizeIllegalArgumentException - if the page index is less than 0IllegalArgumentException - if the page size is less than or equal to 0public static Page ofSize(int size)
size - the page sizeIllegalArgumentException - if the page size is less than or equal to 0public Page next()
previous()public Page previous()
next()public Page first()
public Page index(int newIndex)
newIndex - the new page indexCopyright © 2020 JBoss by Red Hat. All rights reserved.