package com.uas.account.core;

import java.io.Serializable;
import java.util.List;

public class Page<T> implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int number;
	private int size;
	private int numberOfElements;
	private List<T> content;
	private boolean first;
	private boolean last;
	private long totalElements;

	public Page(int pageNumber, int pageSize, List<T> content, int totalElements) {
		this.number = pageNumber;
		this.size = pageSize;
		this.content = content;
		this.numberOfElements = content == null || content.isEmpty() ? 0 : content.size();
		this.totalElements = totalElements;
		this.first = pageNumber == 1;
		this.last = pageNumber >= (int) Math.floor((double) totalElements / pageSize);
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getNumberOfElements() {
		return numberOfElements;
	}

	public void setNumberOfElements(int numberOfElements) {
		this.numberOfElements = numberOfElements;
	}

	public List<T> getContent() {
		return content;
	}

	public void setContent(List<T> content) {
		this.content = content;
	}

	public boolean isFirst() {
		return first;
	}

	public void setFirst(boolean first) {
		this.first = first;
	}

	public boolean isLast() {
		return last;
	}

	public void setLast(boolean last) {
		this.last = last;
	}

	public long getTotalElements() {
		return totalElements;
	}

	public void setTotalElements(long totalElements) {
		this.totalElements = totalElements;
	}

}
