Record Class PageRequest
java.lang.Object
java.lang.Record
cloud.opencode.base.core.page.PageRequest
- Record Components:
page- the page number (1-based) | 页码(从 1 开始)size- the page size | 每页大小sort- the sort criteria | 排序条件
PageRequest - Immutable pagination request with sorting
分页请求 - 带排序的不可变分页请求
Represents a request for a specific page of data with optional sorting.
Page numbering is 1-based. Compatible with Spring Data Pageable semantics
but has no dependency on Spring Data Commons.
表示带可选排序的特定分页数据请求。页码从 1 开始。
与 Spring Data Pageable 语义兼容,但不依赖 Spring Data Commons。
Usage Examples | 使用示例:
PageRequest req = PageRequest.of(1, 20, Sort.by("name"));
PageRequest next = req.next();
long offset = req.getOffset(); // (page - 1) * size
Features | 主要功能:
- Immutable pagination request with sorting - 带排序的不可变分页请求
- 1-based page numbering - 基于1的页码
- Navigation methods: next(), previous(), first() - 导航方法: next()、previous()、first()
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: Yes, sort defaults to unsorted - 空值安全: 是,排序默认为未排序
- Since:
- JDK 25, opencode-base-core V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPageRequest(long page, long size, Sort sort) Creates an instance of aPageRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.first()longfinal inthashCode()Returns a hash code value for this object.booleanisFirst()next()static PageRequestof(long page, long size) static PageRequeststatic PageRequestofSize(long size) longpage()Returns the value of thepagerecord component.previous()longsize()Returns the value of thesizerecord component.sort()Returns the value of thesortrecord component.<T> Page<T> toPage()Creates an emptyPagematching this request's page number and size.toString()Returns a string representation of this record class.withPage(long newPage)
-
Constructor Details
-
PageRequest
-
-
Method Details
-
of
-
of
-
ofSize
-
getOffset
public long getOffset() -
isFirst
public boolean isFirst() -
next
-
previous
-
first
-
withSort
-
withPage
-
toPage
-
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
-