mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
use google guava for hasCode, toString and equals method of repository object
This commit is contained in:
@@ -35,6 +35,8 @@ package sonia.scm.repository;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
import sonia.scm.BasicPropertiesAware;
|
import sonia.scm.BasicPropertiesAware;
|
||||||
import sonia.scm.ModelObject;
|
import sonia.scm.ModelObject;
|
||||||
import sonia.scm.util.Util;
|
import sonia.scm.util.Util;
|
||||||
@@ -183,75 +185,18 @@ public class Repository extends BasicPropertiesAware implements ModelObject
|
|||||||
|
|
||||||
final Repository other = (Repository) obj;
|
final Repository other = (Repository) obj;
|
||||||
|
|
||||||
if ((this.contact == null)
|
//J-
|
||||||
? (other.contact != null)
|
return Objects.equal(id, other.id)
|
||||||
: !this.contact.equals(other.contact))
|
&& Objects.equal(name, other.name)
|
||||||
{
|
&& Objects.equal(contact, other.contact)
|
||||||
return false;
|
&& Objects.equal(description, other.description)
|
||||||
}
|
&& Objects.equal(publicReadable, other.publicReadable)
|
||||||
|
&& Objects.equal(permissions, other.permissions)
|
||||||
if ((this.creationDate != other.creationDate)
|
&& Objects.equal(type, other.type)
|
||||||
&& ((this.creationDate == null)
|
&& Objects.equal(url, other.url)
|
||||||
||!this.creationDate.equals(other.creationDate)))
|
&& Objects.equal(creationDate, other.creationDate)
|
||||||
{
|
&& Objects.equal(lastModified, other.lastModified);
|
||||||
return false;
|
//J+
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.description == null)
|
|
||||||
? (other.description != null)
|
|
||||||
: !this.description.equals(other.description))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.id == null)
|
|
||||||
? (other.id != null)
|
|
||||||
: !this.id.equals(other.id))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.lastModified != other.lastModified)
|
|
||||||
&& ((this.lastModified == null)
|
|
||||||
||!this.lastModified.equals(other.lastModified)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.name == null)
|
|
||||||
? (other.name != null)
|
|
||||||
: !this.name.equals(other.name))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.permissions != other.permissions)
|
|
||||||
&& ((this.permissions == null)
|
|
||||||
||!this.permissions.equals(other.permissions)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.publicReadable != other.publicReadable)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.type == null)
|
|
||||||
? (other.type != null)
|
|
||||||
: !this.type.equals(other.type))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.url == null)
|
|
||||||
? (other.url != null)
|
|
||||||
: !this.url.equals(other.url))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,40 +208,8 @@ public class Repository extends BasicPropertiesAware implements ModelObject
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
int hash = 7;
|
return Objects.hashCode(id, name, contact, description, publicReadable,
|
||||||
|
permissions, type, url, creationDate, lastModified);
|
||||||
hash = 61 * hash + ((this.contact != null)
|
|
||||||
? this.contact.hashCode()
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + ((this.creationDate != null)
|
|
||||||
? this.creationDate.hashCode()
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + ((this.description != null)
|
|
||||||
? this.description.hashCode()
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + ((this.id != null)
|
|
||||||
? this.id.hashCode()
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + ((this.lastModified != null)
|
|
||||||
? this.lastModified.hashCode()
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + ((this.name != null)
|
|
||||||
? this.name.hashCode()
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + ((this.permissions != null)
|
|
||||||
? this.permissions.hashCode()
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + (this.publicReadable
|
|
||||||
? 1
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + ((this.type != null)
|
|
||||||
? this.type.hashCode()
|
|
||||||
: 0);
|
|
||||||
hash = 61 * hash + ((this.url != null)
|
|
||||||
? this.url.hashCode()
|
|
||||||
: 0);
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,11 +221,20 @@ public class Repository extends BasicPropertiesAware implements ModelObject
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder buffer = new StringBuilder("Repository{type=");
|
//J-
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
buffer.append(type).append(", name=").append(name).append("}");
|
.add("id", id)
|
||||||
|
.add("name", name)
|
||||||
return buffer.toString();
|
.add("contact", contact)
|
||||||
|
.add("description", description)
|
||||||
|
.add("publicReadable", publicReadable)
|
||||||
|
.add("permissions", permissions)
|
||||||
|
.add("type", type)
|
||||||
|
.add("url", url)
|
||||||
|
.add("lastModified", lastModified)
|
||||||
|
.add("creationDate", creationDate)
|
||||||
|
.toString();
|
||||||
|
//J+
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user