/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ifish.bean;

import java.util.List;

/**
 *
 * @author Administrator
 */
public class PageResult<T> implements java.io.Serializable {

    private static final long serialVersionUID = 1L;
    private int totalCount = 0;
    private int pageSize = 10;
    private int pageNo = 1;
    private int DEF_COUNT = 10;
    private List<T> list;

    public PageResult() {

    }

    public PageResult(int pageNo, int pageSize, int totalCount) {
        setTotalCount(totalCount);
        setPageSize(pageSize);
        setPageNo(pageNo);
    }

    public PageResult(int pageNo, int pageSize, int totalCount, List<T> list) {
        setTotalCount(totalCount);
        setPageSize(pageSize);
        setPageNo(pageNo);
        this.list = list;
    }

    public void setTotalCount(int totalCount) {
        if (totalCount < 0) {
            this.totalCount = 0;
        } else {
            this.totalCount = totalCount;
        }
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setPageSize(int pageSize) {
        if (pageSize < 1) {
            this.pageSize = DEF_COUNT;
        } else {
            this.pageSize = pageSize;
        }
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageNo(int pageNo) {
        if (pageNo < 1) {
            this.pageNo = 1;
        } else {
            this.pageNo = pageNo;
        }
    }

    public int getPageNo() {
        return pageNo;
    }

    public int getFirstResult() {
        return (pageNo - 1) * pageSize;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

}
