package tech.easyflow.common.analyticaldb.page;

public class AnalyticalDBPageRequest {

    private int pageNumber = 1;
    private int pageSize = 20;

    public AnalyticalDBPageRequest() {
    }

    public AnalyticalDBPageRequest(int pageNumber, int pageSize) {
        this.pageNumber = pageNumber;
        this.pageSize = pageSize;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getOffset() {
        int safePageNumber = Math.max(pageNumber, 1);
        return (safePageNumber - 1) * getSafePageSize();
    }

    public int getSafePageSize() {
        return Math.max(pageSize, 1);
    }
}
