org.templateproject.pojo.page.boot.Pagination Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of template-utils-pojo Show documentation
Show all versions of template-utils-pojo Show documentation
Provide some common pojo and some common classes for projects.
The newest version!
package org.templateproject.pojo.page.boot;
import org.templateproject.pojo.page.boot.support.PageSort;
import java.io.Serializable;
import java.util.List;
/**
* Created by wuwenbin on 2017/6/7.
*/
public abstract class Pagination implements Pageable, Serializable {
private final int pageNo;
private final int pageSize;
public Pagination(int pageNo, int pageSize) {
if (pageNo < 0) {
throw new IllegalArgumentException("页码不能小于0");
}
if (pageSize < 1) {
throw new IllegalArgumentException("页面大小不能小于1");
}
this.pageNo = pageNo;
this.pageSize = pageSize;
}
public int getPageNo() {
return pageNo;
}
public int getPageSize() {
return pageSize;
}
public int getPageStart() {
return (pageNo - 1) * pageSize;
}
public int getPageOver() {
return pageNo * pageSize;
}
public abstract PageSort getPageSort();
public abstract int getTotalCount();
public abstract int getTotalPages();
public abstract List getContent();
public abstract boolean hasContent();
public abstract int nextOrLast();
public abstract int previousOrFirst();
public abstract int first();
public abstract int last();
public boolean hasPrevious() {
return pageNo > 1;
}
public boolean hasNext() {
return pageNo < getTotalPages();
}
public boolean isFirst() {
return !hasPrevious();
}
public boolean isLast() {
return !hasNext();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy