content: 
  package com.weiguanjishu.common;
  
  import com.github.pagehelper.Page;
  import lombok.Data;
  
  import java.io.Serializable;
  import java.util.Collection;
  import java.util.List;
  
  
  @Data
  public class PageInfo<T> implements Serializable {
      private static final long serialVersionUID = 1L;
      //当前页
      private int pageNum;
      //每页的数量
      private int pageSize;
      //总记录数
      private long total;
      //总页数
      private int pages;
      //结果集
      private List<T> list;
      //是否为第一页
      private boolean isFirstPage = false;
      //是否为最后一页
      private boolean isLastPage = false;
  
  
      /**
       * 包装Page对象
       */
      public PageInfo(List<T> list) {
          if (list instanceof Page) {
              Page page = (Page) list;
              this.pageNum = page.getPageNum();
              this.pageSize = page.getPageSize();
  
              this.pages = page.getPages();
              this.list = page;
              this.total = page.getTotal();
          } else if (list instanceof Collection) {
              this.pageNum = 1;
              this.pageSize = list.size();
  
              this.pages = 1;
              this.list = list;
              this.total = list.size();
          }
          if (list instanceof Collection) {
              //判断页面边界
              judgePageBoudary();
          }
      }
  
      /**
       * 判定页面边界
       */
      private void judgePageBoudary() {
          isFirstPage = pageNum == 1;
          isLastPage = pageNum == pages;
      }
  
      @Override
      public String toString() {
          final StringBuffer sb = new StringBuffer("PageInfo{");
          sb.append("pageNum=").append(pageNum);
          sb.append(", pageSize=").append(pageSize);
          sb.append(", total=").append(total);
          sb.append(", pages=").append(pages);
          sb.append(", list=").append(list);
          sb.append(", isFirstPage=").append(isFirstPage);
          sb.append(", isLastPage=").append(isLastPage);
          sb.append(", navigatepageNums=");
          sb.append('}');
          return sb.toString();
      }
  
  }
  