Class Page<T>

java.lang.Object
cloud.opencode.base.core.page.Page<T>
Type Parameters:
T - the record type | 记录类型

public class Page<T> extends Object
Page - Pagination result container 分页 - 分页结果容器

Holds paginated query results with metadata including current page, page size, total count, and computed properties like total pages.

保存分页查询结果及元数据,包括当前页、页大小、总数以及总页数等计算属性。

Usage Examples | 使用示例:

Page<User> page = Page.of(1, 10);
page.setTotal(100);
page.setRecords(userList);
long totalPages = page.getPages(); // 10

Features | 主要功能:

  • Pagination result container with metadata - 带元数据的分页结果容器
  • Computed properties: total pages, hasNext, hasPrevious - 计算属性: 总页数、是否有下一页/上一页
  • Generic type parameter for record type - 记录类型的泛型参数

Security | 安全性:

  • Thread-safe: No, mutable state (records, total) - 线程安全: 否,可变状态(记录列表、总数)
  • Null-safe: Yes, defaults to empty list - 空值安全: 是,默认为空列表
Since:
JDK 25, opencode-base-core V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • Page

      public Page()
    • Page

      public Page(long current, long size)
  • Method Details

    • of

      public static <T> Page<T> of(long current, long size)
    • getCurrent

      public long getCurrent()
    • setCurrent

      public Page<T> setCurrent(long current)
    • getSize

      public long getSize()
    • setSize

      public Page<T> setSize(long size)
    • getTotal

      public long getTotal()
    • setTotal

      public Page<T> setTotal(long total)
    • getRecords

      public List<T> getRecords()
    • setRecords

      public Page<T> setRecords(List<T> records)
    • getPages

      public long getPages()
    • hasNext

      public boolean hasNext()
    • hasPrevious

      public boolean hasPrevious()
    • getOffset

      public long getOffset()
    • toString

      public String toString()
      Overrides:
      toString in class Object