Record Class PageRequest
java.lang.Object
java.lang.Record
cloud.opencode.base.web.page.PageRequest
- Record Components:
page- the page number (1-based) | 页码(从1开始)size- the page size | 页大小sort- the sort criteria | 排序条件
Page Request
分页请求
Standard pagination request parameters.
标准分页请求参数。
Features | 主要功能:
- 1-based page numbering with validation - 基于 1 的页码编号并带验证
- Sort criteria support - 排序条件支持
- Page navigation (next, previous, first) - 分页导航(下一页、上一页、第一页)
- SQL offset calculation - SQL 偏移量计算
Usage Examples | 使用示例:
// Simple page request
PageRequest request = PageRequest.of(1, 20);
// With sort
PageRequest request = PageRequest.of(1, 20, "name", "asc");
// Navigation
PageRequest next = request.next();
int offset = request.getOffset();
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: Yes (sort defaults to unsorted) - 空值安全: 是(排序默认为无排序)
- Since:
- JDK 25, opencode-base-web V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPageRequest(int page, int size, Sort sort) Compact constructor with validation 带验证的紧凑构造函数 -
Method Summary
Modifier and TypeMethodDescriptionstatic PageRequestGet default page request 获取默认分页请求final booleanIndicates whether some other object is "equal to" this one.first()Get first page request 获取第一页请求static PageRequestfirst(int size) Get first page request 获取第一页请求intGet offset for SQL 获取SQL偏移量final inthashCode()Returns a hash code value for this object.booleanhasSort()Check if has sort 检查是否有排序next()Get next page request 获取下一页请求static PageRequestof(int page, int size) Create page request 创建分页请求static PageRequestCreate page request with sort 创建带排序的分页请求static PageRequestCreate page request with sort string 创建带排序字符串的分页请求intpage()Returns the value of thepagerecord component.previous()Get previous page request 获取上一页请求intsize()Returns the value of thesizerecord component.sort()Returns the value of thesortrecord component.With ascending sort 使用升序With descending sort 使用降序final StringtoString()Returns a string representation of this record class.withPage(int newPage) With different page 使用不同的页码withSize(int newSize) With different size 使用不同的页大小With different sort 使用不同的排序
-
Constructor Details
-
PageRequest
Compact constructor with validation 带验证的紧凑构造函数
-
-
Method Details
-
of
Create page request 创建分页请求- Parameters:
page- the page number | 页码size- the page size | 页大小- Returns:
- the request | 请求
-
of
Create page request with sort 创建带排序的分页请求- Parameters:
page- the page number | 页码size- the page size | 页大小sort- the sort criteria | 排序条件- Returns:
- the request | 请求
-
of
Create page request with sort string 创建带排序字符串的分页请求- Parameters:
page- the page number | 页码size- the page size | 页大小sortBy- the sort field | 排序字段sortOrder- the sort order (asc/desc) | 排序顺序- Returns:
- the request | 请求
-
defaultRequest
Get default page request 获取默认分页请求- Returns:
- the request | 请求
-
first
Get first page request 获取第一页请求- Parameters:
size- the page size | 页大小- Returns:
- the request | 请求
-
getOffset
public int getOffset()Get offset for SQL 获取SQL偏移量- Returns:
- the offset | 偏移量
-
hasSort
public boolean hasSort()Check if has sort 检查是否有排序- Returns:
- true if has sort | 如果有排序返回true
-
next
-
previous
Get previous page request 获取上一页请求- Returns:
- the previous page request | 上一页请求
-
first
-
withPage
With different page 使用不同的页码- Parameters:
newPage- the new page number | 新页码- Returns:
- the new request | 新请求
-
withSize
With different size 使用不同的页大小- Parameters:
newSize- the new size | 新页大小- Returns:
- the new request | 新请求
-
withSort
With different sort 使用不同的排序- Parameters:
newSort- the new sort | 新排序- Returns:
- the new request | 新请求
-
sortAsc
With ascending sort 使用升序- Parameters:
property- the property | 属性- Returns:
- the new request | 新请求
-
sortDesc
With descending sort 使用降序- Parameters:
property- the property | 属性- Returns:
- the new request | 新请求
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
page
-
size
-
sort
-