implement equals, hashCode and toString of ChangesetPagingResult

This commit is contained in:
Sebastian Sdorra
2013-03-24 13:48:07 +01:00
parent 720d6d3405
commit 294b9013a3
2 changed files with 65 additions and 2 deletions

View File

@@ -33,6 +33,10 @@
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
@@ -47,7 +51,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
/**
* The changeset paging result is used to do a paging over the
* The changeset paging result is used to do a paging over the
* {@link Changeset}s of a {@link Repository}.
*
* @author Sebastian Sdorra
@@ -83,6 +87,45 @@ public class ChangesetPagingResult implements Iterable<Changeset>, Serializable
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final ChangesetPagingResult other = (ChangesetPagingResult) obj;
return Objects.equal(changesets, other.changesets)
&& Objects.equal(total, other.total);
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
return Objects.hashCode(changesets, total);
}
/**
* Returns an iterator which can iterate over the current list of changesets.
*
@@ -103,6 +146,23 @@ public class ChangesetPagingResult implements Iterable<Changeset>, Serializable
return it;
}
/**
* Method description
*
*
* @return
*/
@Override
public String toString()
{
//J-
return Objects.toStringHelper(this)
.add("changesets", changesets)
.add("total", total)
.toString();
//J+
}
//~--- get methods ----------------------------------------------------------
/**

View File

@@ -77,11 +77,14 @@ public final class LogCommandRequest implements Serializable, Resetable
final LogCommandRequest other = (LogCommandRequest) obj;
//J-
return Objects.equal(startChangeset, other.startChangeset)
&& Objects.equal(endChangeset, other.endChangeset)
&& Objects.equal(pagingStart, other.pagingStart)
&& Objects.equal(pagingLimit, other.pagingLimit)
&& Objects.equal(path, other.path) && Objects.equal(branch, other.branch);
&& Objects.equal(path, other.path)
&& Objects.equal(branch, other.branch);
//J+
}
/**