package com.yeejoin.amos.iec104.core.common.request;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

/**
 * 
 * <pre>
 * 分页实体
 * </pre>
 *
 * @author as-chenjiajun
 * @version $Id: CommonPageable.java, v 0.1 2016-12-14 上午10:42:44 as-chenjiajun
 *          Exp $
 */
public class CommonPageable implements Pageable {

	/**
	 * 页号（大于等于0）
	 */
	protected int pageNumber = 0;

	/**
	 * 每页大小（大于等于0）
	 */
	protected int pageSize = 10;

	/**
	 * 起始索引
	 */
	protected int offset = 0;

	/**
	 * 排序
	 */
	protected Sort sort = null;

	public CommonPageable() {
		this.pageNumber = 0;
		this.pageSize = 10;
		this.offset = pageSize * pageNumber;
	}

	public CommonPageable(int pageNumber, int pageSize) {
		this.pageNumber = pageNumber;
		this.pageSize = pageSize;
		this.offset = pageSize * pageNumber;
	}

	public CommonPageable(int pageNumber, int pageSize, Sort sort) {
		this.pageNumber = pageNumber;
		this.pageSize = pageSize;
		this.sort = sort;
		this.offset = pageSize * pageNumber;
	}

	public int getPageNumber() {
		return this.pageNumber;
	}

	public int getPageSize() {
		return pageSize;
	}

	public int getOffset() {
		offset = pageSize * pageNumber;
		return offset;
	}

	public Sort getSort() {
		return sort;
	}

	public Pageable next() {
		return null;
	}

	public Pageable previousOrFirst() {
		return null;
	}

	public Pageable first() {
		return null;
	}

	public boolean hasPrevious() {
		return false;
	}

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

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

	public void setSort(Sort sort) {
		this.sort = sort;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

}
