use google guava for hasCode, toString and equals method of modifications object

This commit is contained in:
Sebastian Sdorra
2012-02-26 20:00:48 +01:00
parent 7b541151c5
commit d8419b39a9

View File

@@ -35,6 +35,8 @@ package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
import sonia.scm.util.Util; import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
@@ -112,7 +114,7 @@ public class Modifications implements Serializable
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
/** /**
* Method description * {@inheritDoc}
* *
* *
* @param obj * @param obj
@@ -134,29 +136,13 @@ public class Modifications implements Serializable
final Modifications other = (Modifications) obj; final Modifications other = (Modifications) obj;
if ((this.added != other.added) return Objects.equal(added, other.added)
&& ((this.added == null) ||!this.added.equals(other.added))) && Objects.equal(modified, other.modified)
{ && Objects.equal(removed, other.removed);
return false;
}
if ((this.modified != other.modified)
&& ((this.modified == null) ||!this.modified.equals(other.modified)))
{
return false;
}
if ((this.removed != other.removed)
&& ((this.removed == null) ||!this.removed.equals(other.removed)))
{
return false;
}
return true;
} }
/** /**
* Method description * {@inheritDoc}
* *
* *
* @return * @return
@@ -164,23 +150,11 @@ public class Modifications implements Serializable
@Override @Override
public int hashCode() public int hashCode()
{ {
int hash = 7; return Objects.hashCode(added, modified, removed);
hash = 41 * hash + ((this.added != null)
? this.added.hashCode()
: 0);
hash = 41 * hash + ((this.modified != null)
? this.modified.hashCode()
: 0);
hash = 41 * hash + ((this.removed != null)
? this.removed.hashCode()
: 0);
return hash;
} }
/** /**
* Method description * {@inheritDoc}
* *
* *
* @return * @return