org.fingertip.simpledao.bean.PageResult Maven / Gradle / Ivy
The newest version!
package org.fingertip.simpledao.bean;
import java.util.ArrayList;
import java.util.List;
/**
* 分页结果
* @author W.C.H
*
*/
public class PageResult{
private List items = new ArrayList();
/**
* 总记录数
*/
private long totalCount;
/**
* 总页数
*/
private int totalPage;
/**
* 每页的数据量
*/
private int pageSize;
/**
* 当前页码
*/
private int pageIndex;
/**
* 下一页的页码
*/
private int nextPage = 0;
public PageResult() {
super();
}
public PageResult(List items, long totalCount, int pageSize, int pageIndex) {
super();
this.items = items;
this.totalCount = totalCount;
this.pageSize = pageSize;
this.pageIndex = pageIndex;
if(((double)this.totalCount / (double)pageSize) > pageIndex){
this.nextPage = pageIndex+1;
}else{
this.nextPage = pageIndex;
}
this.totalPage = (int)Math.ceil(((double)this.totalCount / (double)pageSize));
}
public static void main(String[] args) {
System.out.println(new PageResult<>(null, 14, 5, 1));
}
public List getItems() {
return items;
}
public void setItems(List items) {
this.items = items;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public long getTotalCount() {
return totalCount;
}
public void setTotalCount(long totalCount) {
this.totalCount = totalCount;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageIndex() {
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
public int getNextPage() {
return nextPage;
}
public void setNextPage(int nextPage) {
this.nextPage = nextPage;
}
@Override
public String toString() {
return "PageResult [items=" + items + ", totalCount=" + totalCount + ", totalPage=" + totalPage + ", pageSize="
+ pageSize + ", pageIndex=" + pageIndex + ", nextPage=" + nextPage + "]";
}
}