cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [42/50] [abbrv] git commit: updated refs/heads/reporter to 28300b5
Date Wed, 08 Jul 2015 19:20:17 GMT
findbugs equals(obj) implementations go against the contract these are removed from the call
into separate calls

Signed-off-by: Daan Hoogland <daan@onecht.net>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/34629446
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/34629446
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/34629446

Branch: refs/heads/reporter
Commit: 34629446b6db162f6b358c2bb042b7c3844003fd
Parents: 4bba499
Author: Daan Hoogland <daan@onecht.net>
Authored: Fri Jun 26 16:06:17 2015 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Tue Jul 7 13:48:19 2015 +0200

----------------------------------------------------------------------
 .../org/apache/cloudstack/storage/BaseType.java  | 19 ++++++++++++-------
 .../cloudstack/framework/config/ConfigKey.java   |  7 +++++++
 utils/src/com/cloud/utils/net/Ip.java            |  7 +++++++
 utils/src/com/cloud/utils/net/Ip4Address.java    | 14 +++++++++++---
 4 files changed, 37 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34629446/engine/storage/src/org/apache/cloudstack/storage/BaseType.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/BaseType.java b/engine/storage/src/org/apache/cloudstack/storage/BaseType.java
index d92dd8d..6d27772 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/BaseType.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/BaseType.java
@@ -23,18 +23,23 @@ public abstract class BaseType {
     public boolean equals(Object that) {
         if (this == that) {
             return true;
-        }
-        if (that instanceof String) {
-            if (this.toString().equalsIgnoreCase((String)that)) {
-                return true;
-            }
         } else if (that instanceof BaseType) {
             BaseType th = (BaseType)that;
             if (this.toString().equalsIgnoreCase(th.toString())) {
                 return true;
             }
-        } else {
-            return false;
+        }
+        return false;
+    }
+
+    public boolean isSameTypeAs(Object that) {
+        if (this.equals(that)){
+            return true;
+        }
+        if (that instanceof String) {
+            if (this.toString().equalsIgnoreCase((String)that)) {
+                return true;
+            }
         }
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34629446/framework/config/src/org/apache/cloudstack/framework/config/ConfigKey.java
----------------------------------------------------------------------
diff --git a/framework/config/src/org/apache/cloudstack/framework/config/ConfigKey.java b/framework/config/src/org/apache/cloudstack/framework/config/ConfigKey.java
index d39bb5d..09e143e 100644
--- a/framework/config/src/org/apache/cloudstack/framework/config/ConfigKey.java
+++ b/framework/config/src/org/apache/cloudstack/framework/config/ConfigKey.java
@@ -122,6 +122,13 @@ public class ConfigKey<T> {
         if (obj instanceof ConfigKey) {
             ConfigKey<?> that = (ConfigKey<?>)obj;
             return this._name.equals(that._name);
+        }
+        return false;
+    }
+
+    public boolean isSameKeyAs(Object obj) {
+        if(this.equals(obj)) {
+            return true;
         } else if (obj instanceof String) {
             String key = (String)obj;
             return key.equals(_name);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34629446/utils/src/com/cloud/utils/net/Ip.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/Ip.java b/utils/src/com/cloud/utils/net/Ip.java
index e479e21..09312bc 100644
--- a/utils/src/com/cloud/utils/net/Ip.java
+++ b/utils/src/com/cloud/utils/net/Ip.java
@@ -75,6 +75,13 @@ public class Ip implements Serializable, Comparable<Ip> {
     public boolean equals(Object obj) {
         if (obj instanceof Ip) {
             return ip == ((Ip)obj).ip;
+        }
+        return false;
+    }
+
+    public boolean isSameAddressAs(Object obj) {
+        if (this.equals(obj)) {
+            return true;
         } else if (obj instanceof String) {
             return ip == NetUtils.ip2Long((String)obj);
         } else if (obj instanceof Long) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34629446/utils/src/com/cloud/utils/net/Ip4Address.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/Ip4Address.java b/utils/src/com/cloud/utils/net/Ip4Address.java
index 67fe6da..9712a1f 100644
--- a/utils/src/com/cloud/utils/net/Ip4Address.java
+++ b/utils/src/com/cloud/utils/net/Ip4Address.java
@@ -55,15 +55,23 @@ public class Ip4Address {
 
     @Override
     public boolean equals(Object that) {
-        if (that instanceof String) { // Assume that is an ip4 address in String form
-            return _addr.equals(that);
-        } else if (that instanceof Ip4Address) {
+
+        if (that instanceof Ip4Address) {
             Ip4Address ip4 = (Ip4Address)that;
             return this._addr.equals(ip4._addr) && (this._mac == ip4._mac || this._mac.equals(ip4._mac));
         } else {
             return false;
         }
     }
+
+    public boolean isSameAddressAs(Object other) {
+        if (other instanceof String) { // Assume that is an ip4 address in String form
+            return _addr.equals(other);
+        } else {
+            return this.equals(other);
+        }
+    }
+
     @Override
     public int hashCode(){
         return (int)(_mac.hashCode()*_addr.hashCode());


Mime
View raw message