java.lang.Object
java.lang.Record
st.orm.Pageable
- Record Components:
pageNumber- the zero-based page index (must not be negative).pageSize- the maximum number of elements per page (must be positive).orders- the sort orders to apply (may be empty).
public record Pageable(int pageNumber, int pageSize, @Nonnull List<Pageable.Order> orders)
extends Record
Represents a pagination request with a zero-based page number, page size, and optional sort orders.
Use ofSize(int) to create a request for the first page, or of(int, int) for a specific page.
Add sort orders with sortBy(Metamodel) and sortByDescending(Metamodel). Navigation methods
next() and previous() return new instances for adjacent pages, preserving sort orders.
- Since:
- 1.10
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents a sort order for a single metamodel field. -
Constructor Summary
ConstructorsConstructorDescriptionPageable(int pageNumber, int pageSize) Creates a pageable request for the given page number and page size without sort orders.Pageable(int pageNumber, int pageSize, List<Pageable.Order> orders) Creates an instance of aPageablerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.next()Returns a pageable request for the next page, preserving sort orders.static Pageableof(int pageNumber, int pageSize) Creates a pageable request for the given page number and page size without sort orders.longoffset()Returns the offset to use for this page request.static PageableofSize(int pageSize) Creates a pageable request for the first page with the given page size.orders()Returns the value of theordersrecord component.intReturns the value of thepageNumberrecord component.intpageSize()Returns the value of thepageSizerecord component.previous()Returns a pageable request for the previous page, or the first page if already on page 0.Returns a new pageable with an ascending sort order appended for the given field.sortByDescending(Metamodel<?, ?> field) Returns a new pageable with a descending sort order appended for the given field.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Pageable
Creates an instance of aPageablerecord class.- Parameters:
pageNumber- the value for thepageNumberrecord componentpageSize- the value for thepageSizerecord componentorders- the value for theordersrecord component
-
Pageable
public Pageable(int pageNumber, int pageSize) Creates a pageable request for the given page number and page size without sort orders.- Parameters:
pageNumber- the zero-based page index.pageSize- the maximum number of elements per page.
-
-
Method Details
-
of
Creates a pageable request for the given page number and page size without sort orders.- Parameters:
pageNumber- the zero-based page index.pageSize- the maximum number of elements per page.- Returns:
- a pageable request.
-
ofSize
Creates a pageable request for the first page with the given page size.- Parameters:
pageSize- the maximum number of elements per page.- Returns:
- a pageable request for page 0.
-
sortBy
Returns a new pageable with an ascending sort order appended for the given field.- Parameters:
field- the metamodel field to sort by.- Returns:
- a new pageable with the sort order added.
-
sortByDescending
Returns a new pageable with a descending sort order appended for the given field.- Parameters:
field- the metamodel field to sort by in descending order.- Returns:
- a new pageable with the sort order added.
-
next
Returns a pageable request for the next page, preserving sort orders.- Returns:
- a pageable for the next page.
-
previous
Returns a pageable request for the previous page, or the first page if already on page 0. Sort orders are preserved.- Returns:
- a pageable for the previous page.
-
offset
public long offset()Returns the offset to use for this page request.- Returns:
- the offset as a long value.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='. -
pageNumber
public int pageNumber()Returns the value of thepageNumberrecord component.- Returns:
- the value of the
pageNumberrecord component
-
pageSize
public int pageSize()Returns the value of thepageSizerecord component.- Returns:
- the value of the
pageSizerecord component
-
orders
Returns the value of theordersrecord component.- Returns:
- the value of the
ordersrecord component
-