public class PageUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
PageUtil.By |
static class |
PageUtil.Sb |
| Modifier and Type | Field and Description |
|---|---|
static char |
SORT_DELI |
static char |
SORT_DESC |
| Constructor and Description |
|---|
PageUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
dataIndex(int pageNumber,
int pageSize)
Calc the index of the data by current pageNumber and pageSize.
|
static <E> @NotNull List<List<E>> |
paginate(List<E> data,
int pageSize)
paginate a list of data
|
static <E> int |
paginate(List<E> data,
int pageSize,
BiConsumer<Integer,List<E>> consumer)
paginate a list of data
|
static @NotNull List<PageUtil.By> |
sort(String sort)
Constructs the order-by convention string.
|
static @NotNull PageUtil.Sb |
sortBy() |
static int |
totalPage(int totalData,
int pageSize)
Calc the total page by totalData and pageSize.
|
public static final char SORT_DESC
public static final char SORT_DELI
public static int dataIndex(int pageNumber,
int pageSize)
pageNumber - 1-based, not less than 1.pageSize - 1-based, not less than 1.public static int totalPage(int totalData,
int pageSize)
totalData - The total number of data, over 2.1 billion is unthinkablepageSize - pageSize, 1-based, not less than 1.@NotNull public static @NotNull PageUtil.Sb sortBy()
@NotNull public static @NotNull List<PageUtil.By> sort(String sort)
Constructs the order-by convention string. `,` - delimited `key` - means asc `-key` - means desc Automatically remove all whitespace characters via WitheUtil
public static <E> int paginate(List<E> data, int pageSize, BiConsumer<Integer,List<E>> consumer)
E - data Typedata - list of datapageSize - page sizeconsumer - Acceptor of pageNumber and current page dataCopyright © 2023. All rights reserved.