Package br.net.woodstock.rockframework.domain.persistence

Source Code of br.net.woodstock.rockframework.domain.persistence.Page

/*
* This file is part of rockframework.
*
* rockframework is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* rockframework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>;.
*/
package br.net.woodstock.rockframework.domain.persistence;

import java.io.Serializable;

import br.net.woodstock.rockframework.core.RockFrameworkVersion;
import br.net.woodstock.rockframework.core.util.Assert;
import br.net.woodstock.rockframework.core.util.EqualsBuilder;
import br.net.woodstock.rockframework.core.util.HashCodeBuilder;
import br.net.woodstock.rockframework.core.util.ToStringBuilder;

public class Page implements Serializable {

  private static final long  serialVersionUID  = RockFrameworkVersion.VERSION;

  private int          pageNumber;

  private int          resultsPerPage;

  public Page() {
    super();
  }

  public Page(final int pageNumber, final int resultsPerPage) {
    super();
    Assert.greaterThan(pageNumber, 0, "pageNumber");
    Assert.greaterThan(resultsPerPage, 0, "resultsPerPage");
    this.pageNumber = pageNumber;
    this.resultsPerPage = resultsPerPage;
  }

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

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

  public int getResultsPerPage() {
    return this.resultsPerPage;
  }

  public void setResultsPerPage(final int resultsPerPage) {
    this.resultsPerPage = resultsPerPage;
  }

  @Override
  public int hashCode() {
    return new HashCodeBuilder().add(this.getPageNumber()).add(this.getResultsPerPage()).build().intValue();
  }

  @Override
  public boolean equals(final Object obj) {
    if (!(obj instanceof Page)) {
      return false;
    }
    Page other = (Page) obj;
    return new EqualsBuilder().add(this.getPageNumber(), other.getPageNumber()).add(this.getResultsPerPage(), this.getResultsPerPage()).build().booleanValue();
  }

  @Override
  public String toString() {
    return new ToStringBuilder(this.getClass()).add("pageNumber", this.getPageNumber()).add("resultsPerPage", this.getResultsPerPage()).build();
  }

}
TOP

Related Classes of br.net.woodstock.rockframework.domain.persistence.Page

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.