mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-09 00:52:12 +01:00
improve equals, hashCode and toString of plugin information class
This commit is contained in:
@@ -35,6 +35,8 @@ package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import sonia.scm.PlatformType;
|
||||
import sonia.scm.SCMContext;
|
||||
import sonia.scm.util.SystemUtil;
|
||||
@@ -111,6 +113,64 @@ public class PluginCondition implements Cloneable, Serializable
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final PluginCondition other = (PluginCondition) obj;
|
||||
|
||||
return Objects.equal(arch, other.arch)
|
||||
&& Objects.equal(minVersion, other.minVersion)
|
||||
&& Objects.equal(os, other.os);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(arch, minVersion, os);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
//J-
|
||||
return Objects.toStringHelper(this)
|
||||
.add("arch", arch)
|
||||
.add("minVersion", minVersion)
|
||||
.add("os", os)
|
||||
.toString();
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,8 @@ package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import sonia.scm.Validateable;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
@@ -127,88 +129,20 @@ public class PluginInformation implements Validateable, Cloneable, Serializable
|
||||
|
||||
final PluginInformation other = (PluginInformation) obj;
|
||||
|
||||
if ((this.artifactId == null)
|
||||
? (other.artifactId != null)
|
||||
: !this.artifactId.equals(other.artifactId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.author == null)
|
||||
? (other.author != null)
|
||||
: !this.author.equals(other.author))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.category == null)
|
||||
? (other.category != null)
|
||||
: !this.category.equals(other.category))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.condition != other.condition)
|
||||
&& ((this.condition == null) ||!this.condition.equals(other.condition)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.description == null)
|
||||
? (other.description != null)
|
||||
: !this.description.equals(other.description))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.groupId == null)
|
||||
? (other.groupId != null)
|
||||
: !this.groupId.equals(other.groupId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.name == null)
|
||||
? (other.name != null)
|
||||
: !this.name.equals(other.name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.screenshots != other.screenshots)
|
||||
&& ((this.screenshots == null)
|
||||
||!this.screenshots.equals(other.screenshots)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.state != other.state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.url == null)
|
||||
? (other.url != null)
|
||||
: !this.url.equals(other.url))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.version == null)
|
||||
? (other.version != null)
|
||||
: !this.version.equals(other.version))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.wiki == null)
|
||||
? (other.wiki != null)
|
||||
: !this.wiki.equals(other.wiki))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
//J-
|
||||
return Objects.equal(artifactId, other.artifactId)
|
||||
&& Objects.equal(author, other.author)
|
||||
&& Objects.equal(category, other.category)
|
||||
&& Objects.equal(condition, other.condition)
|
||||
&& Objects.equal(description, other.description)
|
||||
&& Objects.equal(groupId, other.groupId)
|
||||
&& Objects.equal(name, other.name)
|
||||
&& Objects.equal(screenshots, other.screenshots)
|
||||
&& Objects.equal(state, other.state)
|
||||
&& Objects.equal(url, other.url)
|
||||
&& Objects.equal(version, other.version)
|
||||
&& Objects.equal(wiki, other.wiki);
|
||||
//J+
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,46 +154,35 @@ public class PluginInformation implements Validateable, Cloneable, Serializable
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = 5;
|
||||
return Objects.hashCode(artifactId, author, category, condition,
|
||||
description, groupId, name, screenshots, state, url, version, wiki);
|
||||
}
|
||||
|
||||
hash = 79 * hash + ((this.artifactId != null)
|
||||
? this.artifactId.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.author != null)
|
||||
? this.author.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.category != null)
|
||||
? this.category.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.condition != null)
|
||||
? this.condition.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.description != null)
|
||||
? this.description.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.groupId != null)
|
||||
? this.groupId.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.name != null)
|
||||
? this.name.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.screenshots != null)
|
||||
? this.screenshots.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.state != null)
|
||||
? this.state.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.url != null)
|
||||
? this.url.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.version != null)
|
||||
? this.version.hashCode()
|
||||
: 0);
|
||||
hash = 79 * hash + ((this.wiki != null)
|
||||
? this.wiki.hashCode()
|
||||
: 0);
|
||||
|
||||
return hash;
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
//J-
|
||||
return Objects.toStringHelper(this)
|
||||
.add("artifactId", artifactId)
|
||||
.add("author", author)
|
||||
.add("category", category)
|
||||
.add("condition", condition)
|
||||
.add("description", description)
|
||||
.add("groupId", groupId)
|
||||
.add("name", name)
|
||||
.add("screenshots", screenshots)
|
||||
.add("state", state)
|
||||
.add("url", url)
|
||||
.add("version", version)
|
||||
.add("wiki", wiki)
|
||||
.toString();
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user