From 294b9013a323ce147e84142c0ca67540f21acc13 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 24 Mar 2013 13:48:07 +0100 Subject: [PATCH] implement equals, hashCode and toString of ChangesetPagingResult --- .../scm/repository/ChangesetPagingResult.java | 62 ++++++++++++++++++- .../scm/repository/spi/LogCommandRequest.java | 5 +- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java b/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java index 0d2faad088..0712ed40af 100644 --- a/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java +++ b/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java @@ -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, 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, 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 ---------------------------------------------------------- /** diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/LogCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/LogCommandRequest.java index feed50abda..21391e4b3a 100644 --- a/scm-core/src/main/java/sonia/scm/repository/spi/LogCommandRequest.java +++ b/scm-core/src/main/java/sonia/scm/repository/spi/LogCommandRequest.java @@ -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+ } /**