From 2301d7d745edd62e0626863ca74262e8541c0b6f Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 26 Feb 2012 20:06:31 +0100 Subject: [PATCH] use google guava for hasCode, toString and equals method of fileobject object --- .../java/sonia/scm/repository/FileObject.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/scm-core/src/main/java/sonia/scm/repository/FileObject.java b/scm-core/src/main/java/sonia/scm/repository/FileObject.java index 44272cb675..089ac48361 100644 --- a/scm-core/src/main/java/sonia/scm/repository/FileObject.java +++ b/scm-core/src/main/java/sonia/scm/repository/FileObject.java @@ -35,6 +35,8 @@ package sonia.scm.repository; //~--- non-JDK imports -------------------------------------------------------- +import com.google.common.base.Objects; + import sonia.scm.LastModifiedAware; //~--- JDK imports ------------------------------------------------------------ @@ -54,6 +56,74 @@ import javax.xml.bind.annotation.XmlRootElement; public class FileObject implements LastModifiedAware { + /** + * {@inheritDoc} + * + * + * @param obj + * + * @return + */ + @Override + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + + if (getClass() != obj.getClass()) + { + return false; + } + + final FileObject other = (FileObject) obj; + + return Objects.equal(name, other.name) && Objects.equal(path, other.path) + && Objects.equal(directory, other.directory) + && Objects.equal(description, other.description) + && Objects.equal(length, other.length) + && Objects.equal(subRepository, other.subRepository) + && Objects.equal(lastModified, other.lastModified); + } + + /** + * {@inheritDoc} + * + * + * @return + */ + @Override + public int hashCode() + { + return Objects.hashCode(name, path, directory, description, length, + subRepository, lastModified); + } + + /** + * {@inheritDoc} + * + * + * @return + */ + @Override + public String toString() + { + //J- + return Objects.toStringHelper(this) + .add("name", name) + .add("path", path) + .add("directory", directory) + .add("description", description) + .add("length", length) + .add("subRepository", subRepository) + .add("lastModified", lastModified) + .toString(); + //J+ + } + + //~--- get methods ---------------------------------------------------------- + /** * Method description *