diff --git a/engine/storage/src/org/apache/cloudstack/storage/BaseType.java b/engine/storage/src/org/apache/cloudstack/storage/BaseType.java index d92dd8def38..6d27772b557 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; } 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 d39bb5d3562..09e143edd79 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 { 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); diff --git a/utils/src/com/cloud/utils/net/Ip.java b/utils/src/com/cloud/utils/net/Ip.java index e479e212448..09312bce212 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 { 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) { diff --git a/utils/src/com/cloud/utils/net/Ip4Address.java b/utils/src/com/cloud/utils/net/Ip4Address.java index 67fe6daee75..9712a1ff4a0 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());