From 4a1e7e0005ad73a2ca26f5e547aba72e6ef85828 Mon Sep 17 00:00:00 2001 From: Andrew Bayer Date: Fri, 18 May 2012 11:39:09 -0700 Subject: [PATCH] Refactoring hashcodes/equals. --- .../jclouds/cloudstack/domain/Account.java | 23 +- .../org/jclouds/cloudstack/domain/Alert.java | 18 +- .../jclouds/cloudstack/domain/ApiKeyPair.java | 11 +- .../domain/AsyncCreateResponse.java | 17 +- .../jclouds/cloudstack/domain/AsyncJob.java | 81 ++---- .../cloudstack/domain/AsyncJobError.java | 20 +- .../cloudstack/domain/Capabilities.java | 32 +-- .../jclouds/cloudstack/domain/Capacity.java | 33 +-- .../jclouds/cloudstack/domain/Cluster.java | 36 +-- .../cloudstack/domain/ConfigurationEntry.java | 20 +- .../cloudstack/domain/DiskOffering.java | 60 +--- .../org/jclouds/cloudstack/domain/Domain.java | 29 +- .../EncryptedPasswordAndPrivateKey.java | 11 +- .../org/jclouds/cloudstack/domain/Event.java | 39 +-- .../cloudstack/domain/FirewallRule.java | 40 +-- .../org/jclouds/cloudstack/domain/Host.java | 138 ++++------ .../cloudstack/domain/IPForwardingRule.java | 93 ++----- .../org/jclouds/cloudstack/domain/ISO.java | 104 +++---- .../cloudstack/domain/ISOExtraction.java | 42 +-- .../cloudstack/domain/ISOPermissions.java | 39 +-- .../cloudstack/domain/IngressRule.java | 72 ++--- .../jclouds/cloudstack/domain/JobResult.java | 9 +- .../cloudstack/domain/LoadBalancerRule.java | 99 ++----- .../cloudstack/domain/LoginResponse.java | 108 ++------ .../org/jclouds/cloudstack/domain/NIC.java | 86 ++---- .../jclouds/cloudstack/domain/Network.java | 201 +++----------- .../cloudstack/domain/NetworkOffering.java | 82 ++---- .../cloudstack/domain/NetworkService.java | 77 ++---- .../org/jclouds/cloudstack/domain/OSType.java | 39 +-- .../org/jclouds/cloudstack/domain/Pod.java | 32 +-- .../cloudstack/domain/PortForwardingRule.java | 79 ++---- .../cloudstack/domain/PublicIPAddress.java | 142 +++------- .../cloudstack/domain/ResourceLimit.java | 17 +- .../cloudstack/domain/SecurityGroup.java | 44 +-- .../cloudstack/domain/ServiceOffering.java | 87 ++---- .../jclouds/cloudstack/domain/Snapshot.java | 18 +- .../cloudstack/domain/SnapshotPolicy.java | 21 +- .../jclouds/cloudstack/domain/SshKeyPair.java | 45 +-- .../cloudstack/domain/StoragePool.java | 59 ++-- .../jclouds/cloudstack/domain/Template.java | 181 ++++-------- .../cloudstack/domain/TemplateExtraction.java | 44 ++- .../cloudstack/domain/TemplatePermission.java | 15 +- .../cloudstack/domain/UsageRecord.java | 70 ++--- .../org/jclouds/cloudstack/domain/User.java | 45 ++- .../jclouds/cloudstack/domain/VMGroup.java | 23 +- .../cloudstack/domain/VirtualMachine.java | 259 ++++-------------- .../cloudstack/domain/VlanIPRange.java | 50 ++-- .../org/jclouds/cloudstack/domain/Volume.java | 112 +++----- .../org/jclouds/cloudstack/domain/Zone.java | 125 +++------ 49 files changed, 927 insertions(+), 2200 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Account.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Account.java index d962601dd2..e73d97e3d3 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Account.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Account.java @@ -27,6 +27,7 @@ import javax.annotation.Nullable; import com.google.common.base.CaseFormat; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.collect.ForwardingSet; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; @@ -637,12 +638,7 @@ public class Account extends ForwardingSet implements Comparable @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; + return Objects.hashCode(domainId, id, name); } @Override @@ -653,16 +649,11 @@ public class Account extends ForwardingSet implements Comparable return false; if (getClass() != obj.getClass()) return false; - Account other = (Account) obj; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; + Account that = (Account) obj; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(name, that.name)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java index e39ba9dce6..647dae11b8 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; + import java.util.Date; /** @@ -99,23 +101,19 @@ public class Alert implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Alert alert = (Alert) o; + Alert that = (Alert) o; - if (id != alert.id) return false; - if (description != null ? !description.equals(alert.description) : alert.description != null) return false; - if (sent != null ? !sent.equals(alert.sent) : alert.sent != null) return false; - if (type != null ? !type.equals(alert.type) : alert.type != null) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(sent, that.sent)) return false; + if (!Objects.equal(type, that.type)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (sent != null ? sent.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - return result; + return Objects.hashCode(id, description, sent, type); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java index 4f8fec19c2..4851c133a3 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -81,19 +82,15 @@ public class ApiKeyPair implements Comparable { ApiKeyPair that = (ApiKeyPair) o; - if (apiKey != null ? !apiKey.equals(that.apiKey) : that.apiKey != null) - return false; - if (secretKey != null ? !secretKey.equals(that.secretKey) : that.secretKey != null) - return false; + if (!Objects.equal(apiKey, that.apiKey)) return false; + if (!Objects.equal(secretKey, that.secretKey)) return false; return true; } @Override public int hashCode() { - int result = apiKey != null ? apiKey.hashCode() : 0; - result = 31 * result + (secretKey != null ? secretKey.hashCode() : 0); - return result; + return Objects.hashCode(apiKey, secretKey); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java index aa56420c17..48e63c5d94 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -60,11 +61,7 @@ public class AsyncCreateResponse { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (jobId ^ (jobId >>> 32)); - return result; + return Objects.hashCode(id, jobId); } @Override @@ -75,11 +72,11 @@ public class AsyncCreateResponse { return false; if (getClass() != obj.getClass()) return false; - AsyncCreateResponse other = (AsyncCreateResponse) obj; - if (id != other.id) - return false; - if (jobId != other.jobId) - return false; + AsyncCreateResponse that = (AsyncCreateResponse) obj; + + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(jobId, that.jobId)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java index cb4cfd25e8..a46cbe35d5 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import java.util.Date; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -346,22 +347,8 @@ public class AsyncJob { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (accountId ^ (accountId >>> 32)); - result = prime * result + ((cmd == null) ? 0 : cmd.hashCode()); - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (instanceId ^ (instanceId >>> 32)); - result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode()); - result = prime * result + ((error == null) ? 0 : error.hashCode()); - result = prime * result + progress; - result = prime * result + ((this.result == null) ? 0 : this.result.hashCode()); - result = prime * result + resultCode.code(); - result = prime * result + ((resultType == null) ? 0 : resultType.hashCode()); - result = prime * result + status.code(); - result = prime * result + userId; - return result; + return Objects.hashCode(accountId, cmd, created, id, instanceId, instanceType, error, progress, + result, resultCode, resultType, status, userId); } @Override @@ -372,51 +359,23 @@ public class AsyncJob { return false; if (getClass() != obj.getClass()) return false; - AsyncJob other = (AsyncJob) obj; - if (accountId != other.accountId) - return false; - if (cmd == null) { - if (other.cmd != null) - return false; - } else if (!cmd.equals(other.cmd)) - return false; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (id != other.id) - return false; - if (instanceId != other.instanceId) - return false; - if (instanceType == null) { - if (other.instanceType != null) - return false; - } else if (!instanceType.equals(other.instanceType)) - return false; - if (error == null) { - if (other.error != null) - return false; - } else if (!error.equals(other.error)) - return false; - if (progress != other.progress) - return false; - if (result == null) { - if (other.result != null) - return false; - } else if (!result.equals(other.result)) - return false; - if (resultCode != other.resultCode) - return false; - if (resultType == null) { - if (other.resultType != null) - return false; - } else if (!resultType.equals(other.resultType)) - return false; - if (status != other.status) - return false; - if (userId != other.userId) - return false; + + AsyncJob that = (AsyncJob) obj; + + if (!Objects.equal(accountId, that.accountId)) return false; + if (!Objects.equal(cmd, that.cmd)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(instanceId, that.instanceId)) return false; + if (!Objects.equal(instanceType, that.instanceType)) return false; + if (!Objects.equal(error, that.error)) return false; + if (!Objects.equal(progress, that.progress)) return false; + if (!Objects.equal(result, that.result)) return false; + if (!Objects.equal(resultCode, that.resultCode)) return false; + if (!Objects.equal(resultType, that.resultType)) return false; + if (!Objects.equal(status, that.status)) return false; + if (!Objects.equal(userId, that.userId)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java index a446dbf42f..f57fbd5e22 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -92,11 +93,7 @@ public class AsyncJobError { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + errorCode.code(); - result = prime * result + ((errorText == null) ? 0 : errorText.hashCode()); - return result; + return Objects.hashCode(errorCode, errorText); } @Override @@ -107,14 +104,11 @@ public class AsyncJobError { return false; if (getClass() != obj.getClass()) return false; - AsyncJobError other = (AsyncJobError) obj; - if (errorCode != other.errorCode) - return false; - if (errorText == null) { - if (other.errorText != null) - return false; - } else if (!errorText.equals(other.errorText)) - return false; + AsyncJobError that = (AsyncJobError) obj; + + if (!Objects.equal(errorCode, that.errorCode)) return false; + if (!Objects.equal(errorText, that.errorText)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java index 027cad05cf..4d83b8bca1 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -129,14 +130,7 @@ public class Capabilities { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (canShareTemplates ? 1231 : 1237); - result = prime * result + ((cloudStackVersion == null) ? 0 : cloudStackVersion.hashCode()); - result = prime * result + (securityGroupsEnabled ? 1231 : 1237); - result = prime * result + (firewallRuleUiEnabled ? 1231 : 1237); - result = prime * result + (supportELB ? 1231 : 1237); - return result; + return Objects.hashCode(canShareTemplates, cloudStackVersion, securityGroupsEnabled, firewallRuleUiEnabled, supportELB); } @Override @@ -147,20 +141,14 @@ public class Capabilities { return false; if (getClass() != obj.getClass()) return false; - Capabilities other = (Capabilities) obj; - if (canShareTemplates != other.canShareTemplates) - return false; - if (cloudStackVersion == null) { - if (other.cloudStackVersion != null) - return false; - } else if (!cloudStackVersion.equals(other.cloudStackVersion)) - return false; - if (securityGroupsEnabled != other.securityGroupsEnabled) - return false; - if (firewallRuleUiEnabled != other.firewallRuleUiEnabled) - return false; - if (supportELB != other.supportELB) - return false; + Capabilities that = (Capabilities) obj; + + if (!Objects.equal(canShareTemplates, that.canShareTemplates)) return false; + if (!Objects.equal(cloudStackVersion, that.cloudStackVersion)) return false; + if (!Objects.equal(securityGroupsEnabled, that.securityGroupsEnabled)) return false; + if (!Objects.equal(firewallRuleUiEnabled, that.firewallRuleUiEnabled)) return false; + if (!Objects.equal(supportELB, that.supportELB)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capacity.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capacity.java index a674727131..a16a74c8ff 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capacity.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capacity.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Map; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.gson.annotations.SerializedName; @@ -202,34 +203,24 @@ public class Capacity implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Capacity capacity = (Capacity) o; + Capacity that = (Capacity) o; - if (capacityTotal != capacity.capacityTotal) return false; - if (capacityUsed != capacity.capacityUsed) return false; - if (Double.compare(capacity.percentUsed, percentUsed) != 0) return false; - if (podId != capacity.podId) return false; - if (zoneId != capacity.zoneId) return false; - if (podName != null ? !podName.equals(capacity.podName) : capacity.podName != null) return false; - if (type != capacity.type) return false; - if (zoneName != null ? !zoneName.equals(capacity.zoneName) : capacity.zoneName != null) return false; + if (!Objects.equal(capacityTotal, that.capacityTotal)) return false; + if (!Objects.equal(capacityUsed, that.capacityUsed)) return false; + if (!Objects.equal(percentUsed, that.percentUsed)) return false; + if (!Objects.equal(podId, that.podId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(podName, that.podName)) return false; + if (!Objects.equal(type, that.type)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result; - long temp; - result = (int) (capacityTotal ^ (capacityTotal >>> 32)); - result = 31 * result + (int) (capacityUsed ^ (capacityUsed >>> 32)); - temp = percentUsed != +0.0d ? Double.doubleToLongBits(percentUsed) : 0L; - result = 31 * result + (int) (temp ^ (temp >>> 32)); - result = 31 * result + (int) (podId ^ (podId >>> 32)); - result = 31 * result + (podName != null ? podName.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(capacityTotal, capacityUsed, percentUsed, podId, podName, + type, zoneId, zoneName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java index cd3714775c..4714939c4a 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java @@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain; import static com.google.common.base.CaseFormat.UPPER_CAMEL; import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -194,35 +195,26 @@ public class Cluster implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Cluster cluster = (Cluster) o; + Cluster that = (Cluster) o; - if (id != cluster.id) return false; - if (podId != cluster.podId) return false; - if (zoneId != cluster.zoneId) return false; - if (allocationState != cluster.allocationState) return false; - if (clusterType != cluster.clusterType) return false; - if (hypervisor != null ? !hypervisor.equals(cluster.hypervisor) : cluster.hypervisor != null) return false; - if (managedState != cluster.managedState) return false; - if (name != null ? !name.equals(cluster.name) : cluster.name != null) return false; - if (podName != null ? !podName.equals(cluster.podName) : cluster.podName != null) return false; - if (zoneName != null ? !zoneName.equals(cluster.zoneName) : cluster.zoneName != null) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(podId, that.podId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(allocationState, that.allocationState)) return false; + if (!Objects.equal(clusterType, that.clusterType)) return false; + if (!Objects.equal(hypervisor, that.hypervisor)) return false; + if (!Objects.equal(managedState, that.managedState)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(podName, that.podName)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0); - result = 31 * result + (clusterType != null ? clusterType.hashCode() : 0); - result = 31 * result + (hypervisor != null ? hypervisor.hashCode() : 0); - result = 31 * result + (managedState != null ? managedState.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (podId ^ (podId >>> 32)); - result = 31 * result + (podName != null ? podName.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(id, allocationState, clusterType, hypervisor, managedState, name, podId, podName, + zoneId, zoneName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ConfigurationEntry.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ConfigurationEntry.java index 475652134c..d3a655bf1b 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ConfigurationEntry.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ConfigurationEntry.java @@ -19,6 +19,8 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; + /** * Representation of the API configuration entry response * @@ -106,25 +108,17 @@ public class ConfigurationEntry implements Comparable { ConfigurationEntry that = (ConfigurationEntry) o; - if (category != null ? !category.equals(that.category) : that.category != null) - return false; - if (description != null ? !description.equals(that.description) : that.description != null) - return false; - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - if (value != null ? !value.equals(that.value) : that.value != null) - return false; + if (!Objects.equal(category, that.category)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(value, that.value)) return false; return true; } @Override public int hashCode() { - int result = category != null ? category.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (value != null ? value.hashCode() : 0); - return result; + return Objects.hashCode(category, description, name, value); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java index 6e2cd0be60..8ea21254b0 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java @@ -24,6 +24,7 @@ import java.util.Date; import java.util.Set; import com.google.common.base.Joiner; +import com.google.common.base.Objects; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -209,18 +210,7 @@ public class DiskOffering implements Comparable { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + (customized ? 1231 : 1237); - result = prime * result + diskSize; - result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - return result; + return Objects.hashCode(created, customized, diskSize, displayText, domain, domainId, id, name, tags); } @Override @@ -231,40 +221,18 @@ public class DiskOffering implements Comparable { return false; if (getClass() != obj.getClass()) return false; - DiskOffering other = (DiskOffering) obj; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (customized != other.customized) - return false; - if (diskSize != other.diskSize) - return false; - if (displayText == null) { - if (other.displayText != null) - return false; - } else if (!displayText.equals(other.displayText)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (tags == null) { - if (other.tags != null) - return false; - } else if (!tags.equals(other.tags)) - return false; + DiskOffering that = (DiskOffering) obj; + + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(customized, that.customized)) return false; + if (!Objects.equal(diskSize, that.diskSize)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(tags, that.tags)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Domain.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Domain.java index 3e1fc7ab0c..577598f456 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Domain.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Domain.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -143,32 +144,22 @@ public class Domain implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Domain domain = (Domain) o; + Domain that = (Domain) o; - if (hasChild != domain.hasChild) return false; - if (id != domain.id) return false; - if (level != domain.level) return false; - if (parentDomainId != domain.parentDomainId) return false; - if (name != null ? !name.equals(domain.name) : domain.name != null) - return false; - if (networkDomain != null ? !networkDomain.equals(domain.networkDomain) : domain.networkDomain != null) - return false; - if (parentDomainName != null ? !parentDomainName.equals(domain.parentDomainName) : domain.parentDomainName != null) - return false; + if (!Objects.equal(hasChild, that.hasChild)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(level, that.level)) return false; + if (!Objects.equal(parentDomainId, that.parentDomainId)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(networkDomain, that.networkDomain)) return false; + if (!Objects.equal(parentDomainName, that.parentDomainName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (hasChild ? 1 : 0); - result = 31 * result + (int) (level ^ (level >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (networkDomain != null ? networkDomain.hashCode() : 0); - result = 31 * result + (int) (parentDomainId ^ (parentDomainId >>> 32)); - result = 31 * result + (parentDomainName != null ? parentDomainName.hashCode() : 0); - return result; + return Objects.hashCode(id, hasChild, level, name, networkDomain, parentDomainId, parentDomainName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/EncryptedPasswordAndPrivateKey.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/EncryptedPasswordAndPrivateKey.java index 40ecd2a476..fcec6d9174 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/EncryptedPasswordAndPrivateKey.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/EncryptedPasswordAndPrivateKey.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; + /** * @author Andrei Savu */ @@ -52,18 +54,15 @@ public class EncryptedPasswordAndPrivateKey { EncryptedPasswordAndPrivateKey that = (EncryptedPasswordAndPrivateKey) o; - if (encryptedPassword != null ? !encryptedPassword.equals(that.encryptedPassword) : that.encryptedPassword != null) - return false; - if (privateKey != null ? !privateKey.equals(that.privateKey) : that.privateKey != null) return false; + if (!Objects.equal(encryptedPassword, that.encryptedPassword)) return false; + if (!Objects.equal(privateKey, that.privateKey)) return false; return true; } @Override public int hashCode() { - int result = encryptedPassword != null ? encryptedPassword.hashCode() : 0; - result = 31 * result + (privateKey != null ? privateKey.hashCode() : 0); - return result; + return Objects.hashCode(encryptedPassword, privateKey); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Event.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Event.java index afeb56c04d..0666114c57 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Event.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Event.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; + import java.util.Date; /** @@ -230,37 +232,26 @@ public class Event implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Event event = (Event) o; + Event that = (Event) o; - if (domainId != event.domainId) return false; - if (id != event.id) return false; - if (account != null ? !account.equals(event.account) : event.account != null) return false; - if (created != null ? !created.equals(event.created) : event.created != null) return false; - if (description != null ? !description.equals(event.description) : event.description != null) return false; - if (domain != null ? !domain.equals(event.domain) : event.domain != null) return false; - if (level != null ? !level.equals(event.level) : event.level != null) return false; - if (parentId != null ? !parentId.equals(event.parentId) : event.parentId != null) return false; - if (state != null ? !state.equals(event.state) : event.state != null) return false; - if (type != null ? !type.equals(event.type) : event.type != null) return false; - if (username != null ? !username.equals(event.username) : event.username != null) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(level, that.level)) return false; + if (!Objects.equal(parentId, that.parentId)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(type, that.type)) return false; + if (!Objects.equal(username, that.username)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (account != null ? account.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (domain != null ? domain.hashCode() : 0); - result = 31 * result + (int) (domainId ^ (domainId >>> 32)); - result = 31 * result + (level != null ? level.hashCode() : 0); - result = 31 * result + (parentId != null ? parentId.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (username != null ? username.hashCode() : 0); - return result; + return Objects.hashCode(id, account, description, created, domain, domainId, level, parentId, state, type, username); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/FirewallRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/FirewallRule.java index a8375b96b7..c53366a2b6 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/FirewallRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/FirewallRule.java @@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain; import java.util.Set; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -233,40 +234,23 @@ public class FirewallRule implements Comparable { FirewallRule that = (FirewallRule) o; - if (endPort != that.endPort) return false; - if (id != that.id) return false; - if (startPort != that.startPort) return false; - if (CIDRs != null ? !CIDRs.equals(that.CIDRs) : that.CIDRs != null) - return false; - if (icmpCode != null ? !icmpCode.equals(that.icmpCode) : that.icmpCode != null) - return false; - if (icmpType != null ? !icmpType.equals(that.icmpType) : that.icmpType != null) - return false; - if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null) - return false; - if (ipAddressId != that.ipAddressId) - return false; - if (protocol != null ? !protocol.equals(that.protocol) : that.protocol != null) - return false; - if (state != null ? !state.equals(that.state) : that.state != null) - return false; + if (!Objects.equal(endPort, that.endPort)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(startPort, that.startPort)) return false; + if (!Objects.equal(CIDRs, that.CIDRs)) return false; + if (!Objects.equal(icmpCode, that.icmpCode)) return false; + if (!Objects.equal(icmpType, that.icmpType)) return false; + if (!Objects.equal(ipAddress, that.ipAddress)) return false; + if (!Objects.equal(ipAddressId, that.ipAddressId)) return false; + if (!Objects.equal(protocol, that.protocol)) return false; + if (!Objects.equal(state, that.state)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (CIDRs != null ? CIDRs.hashCode() : 0); - result = 31 * result + startPort; - result = 31 * result + endPort; - result = 31 * result + (icmpCode != null ? icmpCode.hashCode() : 0); - result = 31 * result + (icmpType != null ? icmpType.hashCode() : 0); - result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); - result = 31 * result + (int) (ipAddressId ^ (ipAddressId >>> 32)); - result = 31 * result + (protocol != null ? protocol.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - return result; + return Objects.hashCode(endPort, id, startPort, CIDRs, icmpCode, icmpType, ipAddress, ipAddressId, protocol, state); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java index 18ae419ab7..2de0e4c58e 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java @@ -23,6 +23,7 @@ import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; import java.util.Date; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -693,101 +694,64 @@ public class Host implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Host host = (Host) o; + Host that = (Host) o; - if (averageLoad != host.averageLoad) return false; - if (clusterId != host.clusterId) return false; - if (cpuNumber != host.cpuNumber) return false; - if (cpuSpeed != host.cpuSpeed) return false; - if (Float.compare(host.cpuWithOverProvisioning, cpuWithOverProvisioning) != 0) return false; - if (diskSizeAllocated != host.diskSizeAllocated) return false; - if (diskSizeTotal != host.diskSizeTotal) return false; - if (hasEnoughCapacity != host.hasEnoughCapacity) return false; - if (id != host.id) return false; - if (jobId != host.jobId) return false; - if (localStorageActive != host.localStorageActive) return false; - if (managementServerId != host.managementServerId) return false; - if (memoryAllocated != host.memoryAllocated) return false; - if (memoryTotal != host.memoryTotal) return false; - if (memoryUsed != host.memoryUsed) return false; - if (networkKbsRead != host.networkKbsRead) return false; - if (networkKbsWrite != host.networkKbsWrite) return false; - if (osCategoryId != host.osCategoryId) return false; - if (osCategoryName != host.osCategoryName) return false; - if (podId != host.podId) return false; - if (zoneId != host.zoneId) return false; - if (allocationState != host.allocationState) return false; - if (capabilities != null ? !capabilities.equals(host.capabilities) : host.capabilities != null) return false; - if (clusterName != null ? !clusterName.equals(host.clusterName) : host.clusterName != null) return false; - if (clusterType != host.clusterType) return false; - if (cpuAllocated != null ? !cpuAllocated.equals(host.cpuAllocated) : host.cpuAllocated != null) return false; - if (cpuUsed != null ? !cpuUsed.equals(host.cpuUsed) : host.cpuUsed != null) return false; - if (created != null ? !created.equals(host.created) : host.created != null) return false; - if (disconnected != null ? !disconnected.equals(host.disconnected) : host.disconnected != null) return false; - if (events != null ? !events.equals(host.events) : host.events != null) return false; - if (hostTags != null ? !hostTags.equals(host.hostTags) : host.hostTags != null) return false; - if (hypervisor != null ? !hypervisor.equals(host.hypervisor) : host.hypervisor != null) return false; - if (ipAddress != null ? !ipAddress.equals(host.ipAddress) : host.ipAddress != null) return false; - if (jobStatus != host.jobStatus) return false; - if (lastPinged != null ? !lastPinged.equals(host.lastPinged) : host.lastPinged != null) return false; - if (name != null ? !name.equals(host.name) : host.name != null) return false; - if (podName != null ? !podName.equals(host.podName) : host.podName != null) return false; - if (removed != null ? !removed.equals(host.removed) : host.removed != null) return false; - if (state != host.state) return false; - if (type != host.type) return false; - if (version != null ? !version.equals(host.version) : host.version != null) return false; - if (zoneName != null ? !zoneName.equals(host.zoneName) : host.zoneName != null) return false; + if (!Objects.equal(averageLoad, that.averageLoad)) return false; + if (!Objects.equal(clusterId, that.clusterId)) return false; + if (!Objects.equal(cpuNumber, that.cpuNumber)) return false; + if (!Objects.equal(cpuSpeed, that.cpuSpeed)) return false; + if (!Objects.equal(cpuWithOverProvisioning, that.cpuWithOverProvisioning)) return false; + if (!Objects.equal(diskSizeAllocated, that.diskSizeAllocated)) return false; + if (!Objects.equal(diskSizeTotal, that.diskSizeTotal)) return false; + if (!Objects.equal(hasEnoughCapacity, that.hasEnoughCapacity)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(jobId, that.jobId)) return false; + if (!Objects.equal(localStorageActive, that.localStorageActive)) return false; + if (!Objects.equal(managementServerId, that.managementServerId)) return false; + if (!Objects.equal(memoryAllocated, that.memoryAllocated)) return false; + if (!Objects.equal(memoryTotal, that.memoryTotal)) return false; + if (!Objects.equal(memoryUsed, that.memoryUsed)) return false; + if (!Objects.equal(networkKbsRead, that.networkKbsRead)) return false; + if (!Objects.equal(networkKbsWrite, that.networkKbsWrite)) return false; + if (!Objects.equal(osCategoryId, that.osCategoryId)) return false; + if (!Objects.equal(osCategoryName, that.osCategoryName)) return false; + if (!Objects.equal(podId, that.podId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(allocationState, that.allocationState)) return false; + if (!Objects.equal(capabilities, that.capabilities)) return false; + if (!Objects.equal(clusterName, that.clusterName)) return false; + if (!Objects.equal(clusterType, that.clusterType)) return false; + if (!Objects.equal(cpuAllocated, that.cpuAllocated)) return false; + if (!Objects.equal(cpuUsed, that.cpuUsed)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(disconnected, that.disconnected)) return false; + if (!Objects.equal(events, that.events)) return false; + if (!Objects.equal(hostTags, that.hostTags)) return false; + if (!Objects.equal(hypervisor, that.hypervisor)) return false; + if (!Objects.equal(ipAddress, that.ipAddress)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + if (!Objects.equal(lastPinged, that.lastPinged)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(podName, that.podName)) return false; + if (!Objects.equal(removed, that.removed)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(type, that.type)) return false; + if (!Objects.equal(version, that.version)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0); - result = 31 * result + averageLoad; - result = 31 * result + (capabilities != null ? capabilities.hashCode() : 0); - result = 31 * result + (int) (clusterId ^ (clusterId >>> 32)); - result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0); - result = 31 * result + (clusterType != null ? clusterType.hashCode() : 0); - result = 31 * result + (cpuAllocated != null ? cpuAllocated.hashCode() : 0); - result = 31 * result + cpuNumber; - result = 31 * result + cpuSpeed; - result = 31 * result + (cpuUsed != null ? cpuUsed.hashCode() : 0); - result = 31 * result + (cpuWithOverProvisioning != +0.0f ? Float.floatToIntBits(cpuWithOverProvisioning) : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (disconnected != null ? disconnected.hashCode() : 0); - result = 31 * result + (int) (diskSizeAllocated ^ (diskSizeAllocated >>> 32)); - result = 31 * result + (int) (diskSizeTotal ^ (diskSizeTotal >>> 32)); - result = 31 * result + (events != null ? events.hashCode() : 0); - result = 31 * result + (hasEnoughCapacity ? 1 : 0); - result = 31 * result + (hostTags != null ? hostTags.hashCode() : 0); - result = 31 * result + (hypervisor != null ? hypervisor.hashCode() : 0); - result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); - result = 31 * result + (localStorageActive ? 1 : 0); - result = 31 * result + (int) (jobId ^ (jobId >>> 32)); - result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0); - result = 31 * result + (lastPinged != null ? lastPinged.hashCode() : 0); - result = 31 * result + (int) (managementServerId ^ (managementServerId >>> 32)); - result = 31 * result + (int) (memoryAllocated ^ (memoryAllocated >>> 32)); - result = 31 * result + (int) (memoryTotal ^ (memoryTotal >>> 32)); - result = 31 * result + (int) (memoryUsed ^ (memoryUsed >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (networkKbsRead ^ (networkKbsRead >>> 32)); - result = 31 * result + (int) (networkKbsWrite ^ (networkKbsWrite >>> 32)); - result = 31 * result + (int) (osCategoryId ^ (osCategoryId >>> 32)); - result = 31 * result + (int) (osCategoryName ^ (osCategoryName >>> 32)); - result = 31 * result + (int) (podId ^ (podId >>> 32)); - result = 31 * result + (podName != null ? podName.hashCode() : 0); - result = 31 * result + (removed != null ? removed.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(averageLoad, clusterId, cpuNumber, cpuSpeed, cpuWithOverProvisioning, diskSizeAllocated, + diskSizeTotal, hasEnoughCapacity, id, jobId, localStorageActive, managementServerId, + memoryAllocated, memoryTotal, memoryUsed, networkKbsRead, networkKbsWrite, osCategoryId, + osCategoryName, podId, zoneId, allocationState, capabilities, clusterName, clusterType, + cpuAllocated, cpuUsed, created, disconnected, events, hostTags, hypervisor, ipAddress, + jobStatus, lastPinged, name, podName, removed, state, type, version, zoneName); } - + @Override public String toString() { return "Host{" + diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IPForwardingRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IPForwardingRule.java index 4dca3a0c52..ac9aa5ac1d 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IPForwardingRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IPForwardingRule.java @@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain; import java.util.Collections; import java.util.Set; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.gson.annotations.SerializedName; @@ -280,76 +281,34 @@ public class IPForwardingRule implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode()); - result = prime * result + (int) (IPAddressId ^ (IPAddressId >>> 32)); - result = prime * result + endPort; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); - result = prime * result + startPort; - result = prime * result + publicEndPort; - result = prime * result + privateEndPort; - result = prime * result + publicPort; - result = prime * result + ((state == null) ? 0 : state.hashCode()); - result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode()); - result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32)); - result = prime * result + ((virtualMachineName == null) ? 0 : virtualMachineName.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + IPForwardingRule that = (IPForwardingRule) o; + + if (!Objects.equal(IPAddress, that.IPAddress)) return false; + if (!Objects.equal(IPAddressId, that.IPAddressId)) return false; + if (!Objects.equal(endPort, that.endPort)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(protocol, that.protocol)) return false; + if (!Objects.equal(startPort, that.startPort)) return false; + if (!Objects.equal(publicEndPort, that.publicEndPort)) return false; + if (!Objects.equal(privateEndPort, that.privateEndPort)) return false; + if (!Objects.equal(publicPort, that.publicPort)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false; + if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false; + if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - IPForwardingRule other = (IPForwardingRule) obj; - if (IPAddress == null) { - if (other.IPAddress != null) - return false; - } else if (!IPAddress.equals(other.IPAddress)) - return false; - if (IPAddressId != other.IPAddressId) - return false; - if (endPort != other.endPort) - return false; - if (publicPort != other.publicPort) - return false; - if (publicEndPort != other.publicEndPort) - return false; - if (privateEndPort != other.privateEndPort) - return false; - if (id != other.id) - return false; - if (protocol == null) { - if (other.protocol != null) - return false; - } else if (!protocol.equals(other.protocol)) - return false; - if (startPort != other.startPort) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - if (virtualMachineDisplayName == null) { - if (other.virtualMachineDisplayName != null) - return false; - } else if (!virtualMachineDisplayName.equals(other.virtualMachineDisplayName)) - return false; - if (virtualMachineId != other.virtualMachineId) - return false; - if (virtualMachineName == null) { - if (other.virtualMachineName != null) - return false; - } else if (!virtualMachineName.equals(other.virtualMachineName)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(IPAddress, IPAddressId, endPort, id, protocol, startPort, publicEndPort, + privateEndPort, publicPort, state, virtualMachineDisplayName, + virtualMachineId, virtualMachineName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISO.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISO.java index b38b81509d..82462a4b51 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISO.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISO.java @@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Date; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -613,79 +614,50 @@ public class ISO implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - ISO iso = (ISO) o; + ISO that = (ISO) o; - if (accountId != iso.accountId) return false; - if (bootable != iso.bootable) return false; - if (crossZones != iso.crossZones) return false; - if (domainid != iso.domainid) return false; - if (hostId != iso.hostId) return false; - if (id != iso.id) return false; - if (isExtractable != iso.isExtractable) return false; - if (isFeatured != iso.isFeatured) return false; - if (isPublic != iso.isPublic) return false; - if (isReady != iso.isReady) return false; - if (jobId != iso.jobId) return false; - if (osTypeId != iso.osTypeId) return false; - if (passwordEnabled != iso.passwordEnabled) return false; - if (size != iso.size) return false; - if (sourceTemplateId != iso.sourceTemplateId) return false; - if (zoneId != iso.zoneId) return false; - if (account != null ? !account.equals(iso.account) : iso.account != null) return false; - if (checksum != null ? !checksum.equals(iso.checksum) : iso.checksum != null) return false; - if (created != null ? !created.equals(iso.created) : iso.created != null) return false; - if (displayText != null ? !displayText.equals(iso.displayText) : iso.displayText != null) return false; - if (domain != null ? !domain.equals(iso.domain) : iso.domain != null) return false; - if (format != null ? !format.equals(iso.format) : iso.format != null) return false; - if (hostName != null ? !hostName.equals(iso.hostName) : iso.hostName != null) return false; - if (hypervisor != null ? !hypervisor.equals(iso.hypervisor) : iso.hypervisor != null) return false; - if (jobStatus != null ? !jobStatus.equals(iso.jobStatus) : iso.jobStatus != null) return false; - if (name != null ? !name.equals(iso.name) : iso.name != null) return false; - if (osTypeName != null ? !osTypeName.equals(iso.osTypeName) : iso.osTypeName != null) return false; - if (removed != null ? !removed.equals(iso.removed) : iso.removed != null) return false; - if (status != null ? !status.equals(iso.status) : iso.status != null) return false; - if (templateTag != null ? !templateTag.equals(iso.templateTag) : iso.templateTag != null) return false; - if (templateType != null ? !templateType.equals(iso.templateType) : iso.templateType != null) return false; - if (zoneName != null ? !zoneName.equals(iso.zoneName) : iso.zoneName != null) return false; + if (!Objects.equal(accountId, that.accountId)) return false; + if (!Objects.equal(bootable, that.bootable)) return false; + if (!Objects.equal(crossZones, that.crossZones)) return false; + if (!Objects.equal(domainid, that.domainid)) return false; + if (!Objects.equal(hostId, that.hostId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isExtractable, that.isExtractable)) return false; + if (!Objects.equal(isPublic, that.isPublic)) return false; + if (!Objects.equal(isReady, that.isReady)) return false; + if (!Objects.equal(jobId, that.jobId)) return false; + if (!Objects.equal(osTypeId, that.osTypeId)) return false; + if (!Objects.equal(passwordEnabled, that.passwordEnabled)) return false; + if (!Objects.equal(size, that.size)) return false; + if (!Objects.equal(sourceTemplateId, that.sourceTemplateId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(checksum, that.checksum)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(format, that.format)) return false; + if (!Objects.equal(hostName, that.hostName)) return false; + if (!Objects.equal(hypervisor, that.hypervisor)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(osTypeName, that.osTypeName)) return false; + if (!Objects.equal(removed, that.removed)) return false; + if (!Objects.equal(status, that.status)) return false; + if (!Objects.equal(templateTag, that.templateTag)) return false; + if (!Objects.equal(templateType, that.templateType)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (account != null ? account.hashCode() : 0); - result = 31 * result + (int) (accountId ^ (accountId >>> 32)); - result = 31 * result + (bootable ? 1 : 0); - result = 31 * result + (checksum != null ? checksum.hashCode() : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (crossZones ? 1 : 0); - result = 31 * result + (displayText != null ? displayText.hashCode() : 0); - result = 31 * result + (domain != null ? domain.hashCode() : 0); - result = 31 * result + (int) (domainid ^ (domainid >>> 32)); - result = 31 * result + (format != null ? format.hashCode() : 0); - result = 31 * result + (int) (hostId ^ (hostId >>> 32)); - result = 31 * result + (hostName != null ? hostName.hashCode() : 0); - result = 31 * result + (hypervisor != null ? hypervisor.hashCode() : 0); - result = 31 * result + (isExtractable ? 1 : 0); - result = 31 * result + (isFeatured ? 1 : 0); - result = 31 * result + (isPublic ? 1 : 0); - result = 31 * result + (isReady ? 1 : 0); - result = 31 * result + (int) (jobId ^ (jobId >>> 32)); - result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (osTypeId ^ (osTypeId >>> 32)); - result = 31 * result + (osTypeName != null ? osTypeName.hashCode() : 0); - result = 31 * result + (passwordEnabled ? 1 : 0); - result = 31 * result + (removed != null ? removed.hashCode() : 0); - result = 31 * result + (int) (size ^ (size >>> 32)); - result = 31 * result + (int) (sourceTemplateId ^ (sourceTemplateId >>> 32)); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (templateTag != null ? templateTag.hashCode() : 0); - result = 31 * result + (templateType != null ? templateType.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(accountId, bootable, crossZones, domainid, hostId, id, isExtractable, + isPublic, isReady, jobId, osTypeId, passwordEnabled, size, sourceTemplateId, + zoneId, account, checksum, created, displayText, domain, format, hostName, + hypervisor, jobStatus, name, osTypeName, removed, status, templateTag, + templateType, zoneName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOExtraction.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOExtraction.java index 9fb91087c4..9961de23cd 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOExtraction.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOExtraction.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import java.util.Date; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -276,39 +277,26 @@ public class ISOExtraction implements Comparable { ISOExtraction that = (ISOExtraction) o; - if (accountId != that.accountId) return false; - if (extractId != that.extractId) return false; - if (id != that.id) return false; - if (uploadPercentage != that.uploadPercentage) return false; - if (zoneId != that.zoneId) return false; - if (created != null ? !created.equals(that.created) : that.created != null) return false; - if (extractMode != that.extractMode) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (state != null ? !state.equals(that.state) : that.state != null) return false; - if (status != null ? !status.equals(that.status) : that.status != null) return false; - if (storageType != null ? !storageType.equals(that.storageType) : that.storageType != null) return false; - if (url != null ? !url.equals(that.url) : that.url != null) return false; - if (zoneName != null ? !zoneName.equals(that.zoneName) : that.zoneName != null) return false; + if (!Objects.equal(accountId, that.accountId)) return false; + if (!Objects.equal(extractId, that.extractId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(uploadPercentage, that.uploadPercentage)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(extractMode, that.extractMode)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(status, that.status)) return false; + if (!Objects.equal(storageType, that.storageType)) return false; + if (!Objects.equal(url, that.url)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (accountId ^ (accountId >>> 32)); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (int) (extractId ^ (extractId >>> 32)); - result = 31 * result + (extractMode != null ? extractMode.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (storageType != null ? storageType.hashCode() : 0); - result = 31 * result + uploadPercentage; - result = 31 * result + (url != null ? url.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(accountId, extractId, id, uploadPercentage, zoneId, created, extractMode, name, state, status, storageType, url, zoneName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOPermissions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOPermissions.java index ac0214507f..f03f3ac0ab 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOPermissions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOPermissions.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import java.util.Set; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -115,37 +116,23 @@ public class ISOPermissions implements Comparable { } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ISOPermissions other = (ISOPermissions) obj; - if (accounts == null) { - if (other.accounts != null) - return false; - } else if (!accounts.equals(other.accounts)) - return false; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (isPublic != other.isPublic) - return false; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ISOPermissions that = (ISOPermissions) o; + + if (!Objects.equal(accounts, that.accounts)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isPublic, that.isPublic)) return false; + return true; } @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accounts == null) ? 0 : accounts.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isPublic ? 1231 : 1237); - return result; + return Objects.hashCode(accounts, domainId, id, isPublic); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IngressRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IngressRule.java index 4012e48101..6224a32ad1 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IngressRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IngressRule.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import static com.google.common.base.Preconditions.checkArgument; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -197,61 +198,28 @@ public class IngressRule implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((CIDR == null) ? 0 : CIDR.hashCode()); - result = prime * result + ICMPCode; - result = prime * result + ICMPType; - result = prime * result + ((account == null) ? 0 : account.hashCode()); - result = prime * result + endPort; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); - result = prime * result + ((securityGroupName == null) ? 0 : securityGroupName.hashCode()); - result = prime * result + startPort; - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + IngressRule that = (IngressRule) o; + + if (!Objects.equal(CIDR, that.CIDR)) return false; + if (!Objects.equal(ICMPCode, that.ICMPCode)) return false; + if (!Objects.equal(ICMPType, that.ICMPType)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(endPort, that.endPort)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(protocol, that.protocol)) return false; + if (!Objects.equal(securityGroupName, that.securityGroupName)) return false; + if (!Objects.equal(startPort, that.startPort)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - IngressRule other = (IngressRule) obj; - if (CIDR == null) { - if (other.CIDR != null) - return false; - } else if (!CIDR.equals(other.CIDR)) - return false; - if (ICMPCode != other.ICMPCode) - return false; - if (ICMPType != other.ICMPType) - return false; - if (account == null) { - if (other.account != null) - return false; - } else if (!account.equals(other.account)) - return false; - if (endPort != other.endPort) - return false; - if (id != other.id) - return false; - if (protocol == null) { - if (other.protocol != null) - return false; - } else if (!protocol.equals(other.protocol)) - return false; - if (securityGroupName == null) { - if (other.securityGroupName != null) - return false; - } else if (!securityGroupName.equals(other.securityGroupName)) - return false; - if (startPort != other.startPort) - return false; - return true; + public int hashCode() { + return Objects.hashCode(CIDR, ICMPCode, ICMPType, account, endPort, id, protocol, securityGroupName, startPort); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/JobResult.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/JobResult.java index 823114a62a..f6b3bc469d 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/JobResult.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/JobResult.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -60,17 +61,15 @@ public class JobResult implements Comparable { JobResult that = (JobResult) o; - if (success != that.success) return false; - if (displayText != null ? !displayText.equals(that.displayText) : that.displayText != null) return false; + if (!Objects.equal(success, that.success)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; return true; } @Override public int hashCode() { - int result = (success ? 1 : 0); - result = 31 * result + (displayText != null ? displayText.hashCode() : 0); - return result; + return Objects.hashCode(success, displayText); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java index 5feb52569c..1450a4127d 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Set; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -301,7 +302,7 @@ public class LoadBalancerRule implements Comparable { } /** - * @return the id of the zone the rule belongs to + * @return the id of the zone the rule beStrings to */ public long getZoneId() { return zoneId; @@ -314,82 +315,32 @@ public class LoadBalancerRule implements Comparable { @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((account == null) ? 0 : account.hashCode()); - result = prime * result + ((algorithm == null) ? 0 : algorithm.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + privatePort; - result = prime * result + ((publicIP == null) ? 0 : publicIP.hashCode()); - result = prime * result + (int) (publicIPId ^ (publicIPId >>> 32)); - result = prime * result + publicPort; - result = prime * result + (int) (zoneId ^ (zoneId >>> 32)); - result = prime * result + ((state == null) ? 0 : state.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LoadBalancerRule that = (LoadBalancerRule) o; + + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(algorithm, that.algorithm)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(privatePort, that.privatePort)) return false; + if (!Objects.equal(publicIP, that.publicIP)) return false; + if (!Objects.equal(publicIPId, that.publicIPId)) return false; + if (!Objects.equal(publicPort, that.publicPort)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(state, that.state)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - LoadBalancerRule other = (LoadBalancerRule) obj; - if (account == null) { - if (other.account != null) - return false; - } else if (!account.equals(other.account)) - return false; - if (algorithm == null) { - if (other.algorithm != null) - return false; - } else if (!algorithm.equals(other.algorithm)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (domainId != other.domainId) - return false; - if (zoneId != other.zoneId) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (privatePort != other.privatePort) - return false; - if (publicIP == null) { - if (other.publicIP != null) - return false; - } else if (!publicIP.equals(other.publicIP)) - return false; - if (publicIPId != other.publicIPId) - return false; - if (publicPort != other.publicPort) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(account, algorithm, description, domain, domainId, id, name, privatePort, publicIP, publicIPId, publicPort, zoneId, state); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoginResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoginResponse.java index 9fc2474a2f..3a97d99b81 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoginResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoginResponse.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -242,94 +243,35 @@ public class LoginResponse implements Comparable { } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - LoginResponse other = (LoginResponse) obj; - if (accountName == null) { - if (other.accountName != null) - return false; - } else if (!accountName.equals(other.accountName)) - return false; - if (accountType == null) { - if (other.accountType != null) - return false; - } else if (!accountType.equals(other.accountType)) - return false; - if (domainId != other.domainId) - return false; - if (firstName == null) { - if (other.firstName != null) - return false; - } else if (!firstName.equals(other.firstName)) - return false; - if (jSessionId == null) { - if (other.jSessionId != null) - return false; - } else if (!jSessionId.equals(other.jSessionId)) - return false; - if (lastName == null) { - if (other.lastName != null) - return false; - } else if (!lastName.equals(other.lastName)) - return false; - if (password == null) { - if (other.password != null) - return false; - } else if (!password.equals(other.password)) - return false; - if (registered != other.registered) - return false; - if (sessionKey == null) { - if (other.sessionKey != null) - return false; - } else if (!sessionKey.equals(other.sessionKey)) - return false; - if (timeout != other.timeout) - return false; - if (timezone == null) { - if (other.timezone != null) - return false; - } else if (!timezone.equals(other.timezone)) - return false; - if (timezoneOffset == null) { - if (other.timezoneOffset != null) - return false; - } else if (!timezoneOffset.equals(other.timezoneOffset)) - return false; - if (userId != other.userId) - return false; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LoginResponse that = (LoginResponse) o; + + if (!Objects.equal(accountName, that.accountName)) return false; + if (!Objects.equal(accountType, that.accountType)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(firstName, that.firstName)) return false; + if (!Objects.equal(jSessionId, that.jSessionId)) return false; + if (!Objects.equal(lastName, that.lastName)) return false; + if (!Objects.equal(password, that.password)) return false; + if (!Objects.equal(registered, that.registered)) return false; + if (!Objects.equal(sessionKey, that.sessionKey)) return false; + if (!Objects.equal(timeout, that.timeout)) return false; + if (!Objects.equal(timezone, that.timezone)) return false; + if (!Objects.equal(timezoneOffset, that.timezoneOffset)) return false; + if (!Objects.equal(userId, that.userId)) return false; + if (!Objects.equal(username, that.username)) return false; + return true; } @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accountName == null) ? 0 : accountName.hashCode()); - result = prime * result + ((accountType == null) ? 0 : accountType.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); - result = prime * result + ((jSessionId == null) ? 0 : jSessionId.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((password == null) ? 0 : password.hashCode()); - result = prime * result + (registered ? 1231 : 1237); - result = prime * result + ((sessionKey == null) ? 0 : sessionKey.hashCode()); - result = prime * result + (int) (timeout ^ (timeout >>> 32)); - result = prime * result + ((timezone == null) ? 0 : timezone.hashCode()); - result = prime * result + ((timezoneOffset == null) ? 0 : timezoneOffset.hashCode()); - result = prime * result + (int) (userId ^ (userId >>> 32)); - result = prime * result + ((username == null) ? 0 : username.hashCode()); - return result; + return Objects.hashCode(accountName, accountType, domainId, firstName, jSessionId, lastName, + password, registered, sessionKey, timeout, timezone, timezoneOffset, + userId, username); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NIC.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NIC.java index 22133eb85c..d5b9f7cf74 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NIC.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NIC.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import java.net.URI; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -226,73 +227,30 @@ public class NIC { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode()); - result = prime * result + ((broadcastURI == null) ? 0 : broadcastURI.hashCode()); - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((guestIPType == null) ? 0 : guestIPType.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isDefault ? 1231 : 1237); - result = prime * result + ((isolationURI == null) ? 0 : isolationURI.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - result = prime * result + ((macAddress == null) ? 0 : macAddress.hashCode()); - result = prime * result + (int) (networkId ^ (networkId >>> 32)); - result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NIC that = (NIC) o; + + if (!Objects.equal(IPAddress, that.IPAddress)) return false; + if (!Objects.equal(broadcastURI, that.broadcastURI)) return false; + if (!Objects.equal(gateway, that.gateway)) return false; + if (!Objects.equal(guestIPType, that.guestIPType)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isDefault, that.isDefault)) return false; + if (!Objects.equal(isolationURI, that.isolationURI)) return false; + if (!Objects.equal(netmask, that.netmask)) return false; + if (!Objects.equal(macAddress, that.macAddress)) return false; + if (!Objects.equal(networkId, that.networkId)) return false; + if (!Objects.equal(trafficType, that.trafficType)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NIC other = (NIC) obj; - if (IPAddress == null) { - if (other.IPAddress != null) - return false; - } else if (!IPAddress.equals(other.IPAddress)) - return false; - if (broadcastURI == null) { - if (other.broadcastURI != null) - return false; - } else if (!broadcastURI.equals(other.broadcastURI)) - return false; - if (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (guestIPType != other.guestIPType) - return false; - if (id != other.id) - return false; - if (isDefault != other.isDefault) - return false; - if (isolationURI == null) { - if (other.isolationURI != null) - return false; - } else if (!isolationURI.equals(other.isolationURI)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - if (macAddress == null) { - if (other.macAddress != null) - return false; - } else if (!macAddress.equals(other.macAddress)) - return false; - if (networkId != other.networkId) - return false; - if (trafficType != other.trafficType) - return false; - return true; + public int hashCode() { + return Objects.hashCode(IPAddress, broadcastURI, gateway, guestIPType, id, isDefault, isolationURI, netmask, macAddress, networkId, trafficType); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java index b5bf126503..5f5faeac43 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java @@ -28,6 +28,7 @@ import java.util.SortedSet; import javax.annotation.Nullable; import com.google.common.base.Joiner; +import com.google.common.base.Objects; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -552,166 +553,52 @@ public class Network implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((DNS1 == null) ? 0 : DNS1.hashCode()); - result = prime * result + ((DNS2 == null) ? 0 : DNS2.hashCode()); - result = prime * result + ((VLAN == null) ? 0 : VLAN.hashCode()); - result = prime * result + ((broadcastDomainType == null) ? 0 : broadcastDomainType.hashCode()); - result = prime * result + ((broadcastURI == null) ? 0 : broadcastURI.hashCode()); - result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + ((endIP == null) ? 0 : endIP.hashCode()); - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((guestIPType == null) ? 0 : guestIPType.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isDefault ? 1231 : 1237); - result = prime * result + (isShared ? 1231 : 1237); - result = prime * result + (isSystem ? 1231 : 1237); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - result = prime * result + ((networkDomain == null) ? 0 : networkDomain.hashCode()); - result = prime * result + ((networkOfferingAvailability == null) ? 0 : networkOfferingAvailability.hashCode()); - result = prime * result + ((networkOfferingDisplayText == null) ? 0 : networkOfferingDisplayText.hashCode()); - result = prime * result + (int) (networkOfferingId ^ (networkOfferingId >>> 32)); - result = prime * result + ((networkOfferingName == null) ? 0 : networkOfferingName.hashCode()); - result = prime * result + (int) (related ^ (related >>> 32)); - result = prime * result + ((services == null) ? 0 : services.hashCode()); - result = prime * result + ((startIP == null) ? 0 : startIP.hashCode()); - result = prime * result + ((state == null) ? 0 : state.hashCode()); - result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode()); - result = prime * result + (int) (zoneId ^ (zoneId >>> 32)); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Network that = (Network) o; + + if (!Objects.equal(DNS1, that.DNS1)) return false; + if (!Objects.equal(DNS2, that.DNS2)) return false; + if (!Objects.equal(VLAN, that.VLAN)) return false; + if (!Objects.equal(broadcastDomainType, that.broadcastDomainType)) return false; + if (!Objects.equal(broadcastURI, that.broadcastURI)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(endIP, that.endIP)) return false; + if (!Objects.equal(gateway, that.gateway)) return false; + if (!Objects.equal(guestIPType, that.guestIPType)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isDefault, that.isDefault)) return false; + if (!Objects.equal(isShared, that.isShared)) return false; + if (!Objects.equal(isSystem, that.isSystem)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(netmask, that.netmask)) return false; + if (!Objects.equal(networkDomain, that.networkDomain)) return false; + if (!Objects.equal(networkOfferingAvailability, that.networkOfferingAvailability)) return false; + if (!Objects.equal(networkOfferingDisplayText, that.networkOfferingDisplayText)) return false; + if (!Objects.equal(networkOfferingId, that.networkOfferingId)) return false; + if (!Objects.equal(networkOfferingName, that.networkOfferingName)) return false; + if (!Objects.equal(related, that.related)) return false; + if (!Objects.equal(services, that.services)) return false; + if (!Objects.equal(startIP, that.startIP)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(trafficType, that.trafficType)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(tags, that.tags)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Network other = (Network) obj; - if (DNS1 == null) { - if (other.DNS1 != null) - return false; - } else if (!DNS1.equals(other.DNS1)) - return false; - if (DNS2 == null) { - if (other.DNS2 != null) - return false; - } else if (!DNS2.equals(other.DNS2)) - return false; - if (VLAN == null) { - if (other.VLAN != null) - return false; - } else if (!VLAN.equals(other.VLAN)) - return false; - if (broadcastDomainType == null) { - if (other.broadcastDomainType != null) - return false; - } else if (!broadcastDomainType.equals(other.broadcastDomainType)) - return false; - if (broadcastURI == null) { - if (other.broadcastURI != null) - return false; - } else if (!broadcastURI.equals(other.broadcastURI)) - return false; - if (displayText == null) { - if (other.displayText != null) - return false; - } else if (!displayText.equals(other.displayText)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (endIP == null) { - if (other.endIP != null) - return false; - } else if (!endIP.equals(other.endIP)) - return false; - if (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (guestIPType != other.guestIPType) - return false; - if (id != other.id) - return false; - if (isDefault != other.isDefault) - return false; - if (isShared != other.isShared) - return false; - if (isSystem != other.isSystem) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - if (networkDomain == null) { - if (other.networkDomain != null) - return false; - } else if (!networkDomain.equals(other.networkDomain)) - return false; - if (networkOfferingAvailability == null) { - if (other.networkOfferingAvailability != null) - return false; - } else if (!networkOfferingAvailability.equals(other.networkOfferingAvailability)) - return false; - if (networkOfferingDisplayText == null) { - if (other.networkOfferingDisplayText != null) - return false; - } else if (!networkOfferingDisplayText.equals(other.networkOfferingDisplayText)) - return false; - if (networkOfferingId != other.networkOfferingId) - return false; - if (networkOfferingName == null) { - if (other.networkOfferingName != null) - return false; - } else if (!networkOfferingName.equals(other.networkOfferingName)) - return false; - if (related != other.related) - return false; - if (services == null) { - if (other.services != null) - return false; - } else if (!services.equals(other.services)) - return false; - if (startIP == null) { - if (other.startIP != null) - return false; - } else if (!startIP.equals(other.startIP)) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - if (trafficType != other.trafficType) - return false; - if (zoneId != other.zoneId) - return false; - if (tags == null) { - if (other.tags != null) - return false; - } else if (!tags.equals(other.tags)) - return false; - if (domainId != other.domainId) - return false; - return true; + public int hashCode() { + return Objects.hashCode(DNS1, DNS2, VLAN, broadcastDomainType, broadcastURI, displayText, domain, + endIP, gateway, guestIPType, id, isDefault, isShared, isSystem, name, + netmask, networkDomain, networkOfferingAvailability, networkOfferingDisplayText, + networkOfferingId, networkOfferingName, related, services, startIP, state, + trafficType, zoneId, tags, domainId); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java index d074bd7bb3..cff69666f0 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java @@ -26,6 +26,7 @@ import java.util.Set; import javax.annotation.Nullable; import com.google.common.base.Joiner; +import com.google.common.base.Objects; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -266,70 +267,29 @@ public class NetworkOffering implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((availability == null) ? 0 : availability.hashCode()); - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isDefault ? 1231 : 1237); - result = prime * result + ((maxConnections == null) ? 0 : maxConnections.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + (supportsVLAN ? 1231 : 1237); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkOffering that = (NetworkOffering) o; + + if (!Objects.equal(availability, that.availability)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isDefault, that.isDefault)) return false; + if (!Objects.equal(maxConnections, that.maxConnections)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(supportsVLAN, that.supportsVLAN)) return false; + if (!Objects.equal(tags, that.tags)) return false; + if (!Objects.equal(trafficType, that.trafficType)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NetworkOffering other = (NetworkOffering) obj; - if (availability == null) { - if (other.availability != null) - return false; - } else if (!availability.equals(other.availability)) - return false; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (displayText == null) { - if (other.displayText != null) - return false; - } else if (!displayText.equals(other.displayText)) - return false; - if (id != other.id) - return false; - if (isDefault != other.isDefault) - return false; - if (maxConnections == null) { - if (other.maxConnections != null) - return false; - } else if (!maxConnections.equals(other.maxConnections)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (supportsVLAN != other.supportsVLAN) - return false; - if (tags == null) { - if (other.tags != null) - return false; - } else if (!tags.equals(other.tags)) - return false; - if (trafficType != other.trafficType) - return false; - return true; + public int hashCode() { + return Objects.hashCode(availability, created, displayText, id, isDefault, maxConnections, name, supportsVLAN, tags, trafficType); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java index 39c910507b..71a1db51d0 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.SortedSet; import java.util.Map.Entry; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedSet; @@ -51,34 +52,21 @@ public class NetworkService implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkService.Capability that = (NetworkService.Capability) o; + + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(value, that.value)) return false; + + return true; } - + @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NetworkService.Capability other = (NetworkService.Capability) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(name, value); } @Override @@ -128,34 +116,21 @@ public class NetworkService implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkService that = (NetworkService) o; + + if (!Objects.equal(capabilities, that.capabilities)) return false; + if (!Objects.equal(name, that.name)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NetworkService other = (NetworkService) obj; - if (capabilities == null) { - if (other.capabilities != null) - return false; - } else if (!capabilities.equals(other.capabilities)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(capabilities, name); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java index 314e4d45c4..c5ae4399ee 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -93,34 +94,22 @@ public class OSType implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (OSCategoryId ^ (OSCategoryId >>> 32)); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + OSType that = (OSType) o; + + if (!Objects.equal(OSCategoryId, that.OSCategoryId)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(id, that.id)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - OSType other = (OSType) obj; - if (OSCategoryId != other.OSCategoryId) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (id != other.id) - return false; - return true; + public int hashCode() { + return Objects.hashCode(OSCategoryId, description, id); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Pod.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Pod.java index 2b46bbc8ac..67e76e1530 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Pod.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Pod.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -219,33 +220,24 @@ public class Pod implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Pod pod = (Pod) o; + Pod that = (Pod) o; - if (id != pod.id) return false; - if (zoneId != pod.zoneId) return false; - if (allocationState != pod.allocationState) return false; - if (endIp != null ? !endIp.equals(pod.endIp) : pod.endIp != null) return false; - if (gateway != null ? !gateway.equals(pod.gateway) : pod.gateway != null) return false; - if (name != null ? !name.equals(pod.name) : pod.name != null) return false; - if (netmask != null ? !netmask.equals(pod.netmask) : pod.netmask != null) return false; - if (startIp != null ? !startIp.equals(pod.startIp) : pod.startIp != null) return false; - if (zoneName != null ? !zoneName.equals(pod.zoneName) : pod.zoneName != null) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(allocationState, that.allocationState)) return false; + if (!Objects.equal(endIp, that.endIp)) return false; + if (!Objects.equal(gateway, that.gateway)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(netmask, that.netmask)) return false; + if (!Objects.equal(startIp, that.startIp)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - result = 31 * result + (gateway != null ? gateway.hashCode() : 0); - result = 31 * result + (netmask != null ? netmask.hashCode() : 0); - result = 31 * result + (startIp != null ? startIp.hashCode() : 0); - result = 31 * result + (endIp != null ? endIp.hashCode() : 0); - result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0); - return result; + return Objects.hashCode(id, zoneId, allocationState, endIp, gateway, name, netmask, startIp, zoneName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java index 67c8ddb8ce..644037d4ac 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java @@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain; import java.util.Set; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -301,67 +302,29 @@ public class PortForwardingRule implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode()); - result = prime * result + (int) (IPAddressId ^ (IPAddressId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + privatePort; - result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); - result = prime * result + publicPort; - result = prime * result + ((state == null) ? 0 : state.hashCode()); - result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode()); - result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32)); - result = prime * result + ((virtualMachineName == null) ? 0 : virtualMachineName.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PortForwardingRule that = (PortForwardingRule) o; + + if (!Objects.equal(IPAddress, that.IPAddress)) return false; + if (!Objects.equal(IPAddressId, that.IPAddressId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(privatePort, that.privatePort)) return false; + if (!Objects.equal(protocol, that.protocol)) return false; + if (!Objects.equal(publicPort, that.publicPort)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false; + if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false; + if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PortForwardingRule other = (PortForwardingRule) obj; - if (IPAddress == null) { - if (other.IPAddress != null) - return false; - } else if (!IPAddress.equals(other.IPAddress)) - return false; - if (IPAddressId != other.IPAddressId) - return false; - if (id != other.id) - return false; - if (privatePort != other.privatePort) - return false; - if (protocol == null) { - if (other.protocol != null) - return false; - } else if (!protocol.equals(other.protocol)) - return false; - if (privatePort != other.privatePort) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - if (virtualMachineDisplayName == null) { - if (other.virtualMachineDisplayName != null) - return false; - } else if (!virtualMachineDisplayName.equals(other.virtualMachineDisplayName)) - return false; - if (virtualMachineId != other.virtualMachineId) - return false; - if (virtualMachineName == null) { - if (other.virtualMachineName != null) - return false; - } else if (!virtualMachineName.equals(other.virtualMachineName)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(IPAddress, IPAddressId, id, privatePort, protocol, publicPort, state, virtualMachineDisplayName, virtualMachineId, virtualMachineName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PublicIPAddress.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PublicIPAddress.java index 18d865a01c..55f29049be 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PublicIPAddress.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PublicIPAddress.java @@ -25,6 +25,7 @@ import java.util.Date; import javax.annotation.Nullable; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -425,117 +426,42 @@ public class PublicIPAddress implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode()); - result = prime * result + (int) (VLANId ^ (VLANId >>> 32)); - result = prime * result + ((VLANName == null) ? 0 : VLANName.hashCode()); - result = prime * result + ((account == null) ? 0 : account.hashCode()); - result = prime * result + ((allocated == null) ? 0 : allocated.hashCode()); - result = prime * result + (int) (associatedNetworkId ^ (associatedNetworkId >>> 32)); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isSourceNAT ? 1231 : 1237); - result = prime * result + (isStaticNAT ? 1231 : 1237); - result = prime * result + (int) (networkId ^ (networkId >>> 32)); - result = prime * result + ((state == null) ? 0 : state.hashCode()); - result = prime * result + (usesVirtualNetwork ? 1231 : 1237); - result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode()); - result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32)); - result = prime * result + ((virtualMachineName == null) ? 0 : virtualMachineName.hashCode()); - result = prime * result + (int) (zoneId ^ (zoneId >>> 32)); - result = prime * result + ((zoneName == null) ? 0 : zoneName.hashCode()); - result = prime * result + ((jobStatus == null) ? 0 : jobStatus.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PublicIPAddress that = (PublicIPAddress) o; + + if (!Objects.equal(IPAddress, that.IPAddress)) return false; + if (!Objects.equal(VLANId, that.VLANId)) return false; + if (!Objects.equal(VLANName, that.VLANName)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(allocated, that.allocated)) return false; + if (!Objects.equal(associatedNetworkId, that.associatedNetworkId)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isSourceNAT, that.isSourceNAT)) return false; + if (!Objects.equal(isStaticNAT, that.isStaticNAT)) return false; + if (!Objects.equal(networkId, that.networkId)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(usesVirtualNetwork, that.usesVirtualNetwork)) return false; + if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false; + if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false; + if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PublicIPAddress other = (PublicIPAddress) obj; - if (IPAddress == null) { - if (other.IPAddress != null) - return false; - } else if (!IPAddress.equals(other.IPAddress)) - return false; - if (VLANId != other.VLANId) - return false; - if (VLANName == null) { - if (other.VLANName != null) - return false; - } else if (!VLANName.equals(other.VLANName)) - return false; - if (account == null) { - if (other.account != null) - return false; - } else if (!account.equals(other.account)) - return false; - if (allocated == null) { - if (other.allocated != null) - return false; - } else if (!allocated.equals(other.allocated)) - return false; - if (associatedNetworkId != other.associatedNetworkId) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (isSourceNAT != other.isSourceNAT) - return false; - if (isStaticNAT != other.isStaticNAT) - return false; - if (networkId != other.networkId) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - if (usesVirtualNetwork != other.usesVirtualNetwork) - return false; - if (virtualMachineDisplayName == null) { - if (other.virtualMachineDisplayName != null) - return false; - } else if (!virtualMachineDisplayName.equals(other.virtualMachineDisplayName)) - return false; - if (virtualMachineId != other.virtualMachineId) - return false; - if (virtualMachineName == null) { - if (other.virtualMachineName != null) - return false; - } else if (!virtualMachineName.equals(other.virtualMachineName)) - return false; - if (zoneId != other.zoneId) - return false; - if (zoneName == null) { - if (other.zoneName != null) - return false; - } else if (!zoneName.equals(other.zoneName)) - return false; - if (jobId == null) { - if (other.jobId != null) - return false; - } else if (!jobId.equals(other.jobId)) - return false; - if (jobStatus == null) { - if (other.jobStatus != null) - return false; - } else if (!jobStatus.equals(other.jobStatus)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(IPAddress, VLANId, VLANName, account, allocated, associatedNetworkId, + domain, domainId, id, isSourceNAT, isStaticNAT, networkId, state, + usesVirtualNetwork, virtualMachineDisplayName, virtualMachineId, + virtualMachineName, zoneId, zoneName, jobStatus); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ResourceLimit.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ResourceLimit.java index e10c840c3e..50aaa015a4 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ResourceLimit.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ResourceLimit.java @@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Map; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.gson.annotations.SerializedName; @@ -123,22 +124,18 @@ public class ResourceLimit implements Comparable { ResourceLimit that = (ResourceLimit) o; - if (domainId != that.domainId) return false; - if (max != that.max) return false; - if (resourceType != that.resourceType) return false; - if (!account.equals(that.account)) return false; - if (!domain.equals(that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(max, that.max)) return false; + if (!Objects.equal(resourceType, that.resourceType)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(domain, that.domain)) return false; return true; } @Override public int hashCode() { - int result = account.hashCode(); - result = 31 * result + domain.hashCode(); - result = 31 * result + (int) (domainId ^ (domainId >>> 32)); - result = 31 * result + max; - return result; + return Objects.hashCode(domainId, max, resourceType, account, domain); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SecurityGroup.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SecurityGroup.java index 4301f172ea..09a44d22d8 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SecurityGroup.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SecurityGroup.java @@ -25,6 +25,7 @@ import java.util.SortedSet; import javax.annotation.Nullable; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.gson.annotations.SerializedName; @@ -205,39 +206,22 @@ public class SecurityGroup implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((jobStatus == null) ? 0 : jobStatus.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SecurityGroup that = (SecurityGroup) o; + + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SecurityGroup other = (SecurityGroup) obj; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (jobId == null) { - if (other.jobId != null) - return false; - } else if (!jobId.equals(other.jobId)) - return false; - if (jobStatus == null) { - if (other.jobStatus != null) - return false; - } else if (!jobStatus.equals(other.jobStatus)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(domainId, id, jobStatus); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java index 44f5f26462..06d1ebf459 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java @@ -24,6 +24,7 @@ import java.util.Date; import java.util.Set; import com.google.common.base.Joiner; +import com.google.common.base.Objects; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -341,73 +342,31 @@ public class ServiceOffering implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + cpuNumber; - result = prime * result + cpuSpeed; - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (haSupport ? 1231 : 1237); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + memory; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((storageType == null) ? 0 : storageType.hashCode()); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ServiceOffering that = (ServiceOffering) o; + + if (!Objects.equal(cpuNumber, that.cpuNumber)) return false; + if (!Objects.equal(cpuSpeed, that.cpuSpeed)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(haSupport, that.haSupport)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(memory, that.memory)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(storageType, that.storageType)) return false; + if (!Objects.equal(tags, that.tags)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ServiceOffering other = (ServiceOffering) obj; - if (cpuNumber != other.cpuNumber) - return false; - if (cpuSpeed != other.cpuSpeed) - return false; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (displayText == null) { - if (other.displayText != null) - return false; - } else if (!displayText.equals(other.displayText)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (domainId != other.domainId) - return false; - if (haSupport != other.haSupport) - return false; - if (id != other.id) - return false; - if (memory != other.memory) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (storageType != other.storageType) - return false; - if (tags == null) { - if (other.tags != null) - return false; - } else if (!tags.equals(other.tags)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(cpuNumber, cpuSpeed, created, displayText, domain, domainId, haSupport, id, memory, name, storageType, tags); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java index feafd8f686..fbbb3fcfe1 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java @@ -387,21 +387,9 @@ public class Snapshot implements Comparable { @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (account != null ? account.hashCode() : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (domain != null ? domain.hashCode() : 0); - result = 31 * result + (int) (domainId ^ (domainId >>> 32)); - result = 31 * result + (interval != null ? interval.hashCode() : 0); - result = 31 * result + (int) (jobId ^ (jobId >>> 32)); - result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (snapshotType != null ? snapshotType.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (int) (volumeId ^ (volumeId >>> 32)); - result = 31 * result + (volumeName != null ? volumeName.hashCode() : 0); - result = 31 * result + (volumeType != null ? volumeType.hashCode() : 0); - return result; + return Objects.hashCode(domainId, id, jobId, volumeId, account, created, domain, + interval, jobStatus, name, snapshotType, state, volumeName, + volumeType); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SnapshotPolicy.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SnapshotPolicy.java index 96d645c3c2..44da162d04 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SnapshotPolicy.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SnapshotPolicy.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -165,25 +166,19 @@ public class SnapshotPolicy implements Comparable { SnapshotPolicy that = (SnapshotPolicy) o; - if (id != that.id) return false; - if (numberToRetain != that.numberToRetain) return false; - if (volumeId != that.volumeId) return false; - if (interval != that.interval) return false; - if (schedule != null ? !schedule.equals(that.schedule) : that.schedule != null) return false; - if (timezone != null ? !timezone.equals(that.timezone) : that.timezone != null) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(numberToRetain, that.numberToRetain)) return false; + if (!Objects.equal(volumeId, that.volumeId)) return false; + if (!Objects.equal(interval, that.interval)) return false; + if (!Objects.equal(schedule, that.schedule)) return false; + if (!Objects.equal(timezone, that.timezone)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (interval != null ? interval.hashCode() : 0); - result = 31 * result + (int) (numberToRetain ^ (numberToRetain >>> 32)); - result = 31 * result + (schedule != null ? schedule.hashCode() : 0); - result = 31 * result + (timezone != null ? timezone.hashCode() : 0); - result = 31 * result + (int) (volumeId ^ (volumeId >>> 32)); - return result; + return Objects.hashCode(id, numberToRetain, volumeId, interval, schedule, timezone); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SshKeyPair.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SshKeyPair.java index 134ab5468b..ef36ea3b77 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SshKeyPair.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SshKeyPair.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -85,42 +86,22 @@ public class SshKeyPair implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fingerprint == null) ? 0 : fingerprint.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((privateKey == null) ? 0 : privateKey.hashCode()); + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - return result; + SshKeyPair that = (SshKeyPair) o; + + if (!Objects.equal(fingerprint, that.fingerprint)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(privateKey, that.privateKey)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SshKeyPair other = (SshKeyPair) obj; - if (fingerprint == null) { - if (other.fingerprint != null) - return false; - } else if (!fingerprint.equals(other.fingerprint)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (privateKey == null) { - if (other.privateKey != null) - return false; - } else if (!privateKey.equals(other.privateKey)) - return false; - - return true; + public int hashCode() { + return Objects.hashCode(fingerprint, name, privateKey); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java index 70dbf8e68c..e8a05fdf59 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Date; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -330,49 +331,33 @@ public class StoragePool implements Comparable { StoragePool that = (StoragePool) o; - if (clusterId != that.clusterId) return false; - if (diskSizeAllocated != that.diskSizeAllocated) return false; - if (diskSizeTotal != that.diskSizeTotal) return false; - if (id != that.id) return false; - if (podId != that.podId) return false; - if (zoneId != that.zoneId) return false; - if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) return false; - if (created != null ? !created.equals(that.created) : that.created != null) return false; - if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null) return false; - if (jobId != null ? !jobId.equals(that.jobId) : that.jobId != null) return false; - if (jobStatus != null ? !jobStatus.equals(that.jobStatus) : that.jobStatus != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (path != null ? !path.equals(that.path) : that.path != null) return false; - if (podName != null ? !podName.equals(that.podName) : that.podName != null) return false; - if (state != that.state) return false; - if (tags != null ? !tags.equals(that.tags) : that.tags != null) return false; - if (type != that.type) return false; - if (zoneName != null ? !zoneName.equals(that.zoneName) : that.zoneName != null) return false; + if (!Objects.equal(clusterId, that.clusterId)) return false; + if (!Objects.equal(diskSizeAllocated, that.diskSizeAllocated)) return false; + if (!Objects.equal(diskSizeTotal, that.diskSizeTotal)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(podId, that.podId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(clusterName, that.clusterName)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(ipAddress, that.ipAddress)) return false; + if (!Objects.equal(jobId, that.jobId)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(path, that.path)) return false; + if (!Objects.equal(podName, that.podName)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(tags, that.tags)) return false; + if (!Objects.equal(type, that.type)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (path != null ? path.hashCode() : 0); - result = 31 * result + (tags != null ? tags.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - result = 31 * result + (int) (podId ^ (podId >>> 32)); - result = 31 * result + (podName != null ? podName.hashCode() : 0); - result = 31 * result + (int) (clusterId ^ (clusterId >>> 32)); - result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (int) (diskSizeAllocated ^ (diskSizeAllocated >>> 32)); - result = 31 * result + (int) (diskSizeTotal ^ (diskSizeTotal >>> 32)); - result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); - result = 31 * result + (jobId != null ? jobId.hashCode() : 0); - result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0); - return result; + return Objects.hashCode(clusterId, diskSizeAllocated, diskSizeTotal, id, podId, zoneId, + clusterName, created, ipAddress, jobId, jobStatus, name, path, + podName, state, tags, type, zoneName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java index 68a9d84f03..a3b4ea9eeb 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java @@ -24,6 +24,7 @@ import java.util.Date; import javax.annotation.Nullable; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -599,142 +600,56 @@ public class Template implements Comparable