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

This commit is contained in:
Sebastian Sdorra
2012-02-26 19:45:31 +01:00
parent 37c87a2c5d
commit 532146f0c8

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;
@@ -130,24 +134,8 @@ public class Permission implements Serializable
final Permission other = (Permission) obj;
if (this.groupPermission != other.groupPermission)
{
return false;
}
if ((this.name == null)
? (other.name != null)
: !this.name.equals(other.name))
{
return false;
}
if (this.type != other.type)
{
return false;
}
return true;
return Objects.equal(name, other.name) && Objects.equal(type, other.type)
&& Objects.equal(groupPermission, groupPermission);
}
/**
@@ -159,19 +147,25 @@ public class Permission implements Serializable
@Override
public int hashCode()
{
int hash = 7;
return Objects.hashCode(name, type, groupPermission);
}
hash = 97 * hash + (this.groupPermission
? 1
: 0);
hash = 97 * hash + ((this.name != null)
? this.name.hashCode()
: 0);
hash = 97 * hash + ((this.type != null)
? this.type.hashCode()
: 0);
return hash;
/**
* Method description
*
*
* @return
*/
@Override
public String toString()
{
//J-
return Objects.toStringHelper(this)
.add("name", name)
.add("type", type)
.add("groupPermission", groupPermission)
.toString();
//J+
}
//~--- get methods ----------------------------------------------------------