Five more Equals/HashCode/StringBuilder replacements 51/351/1
authorEd Warnicke <eaw@cisco.com>
Wed, 15 May 2013 16:11:56 +0000 (11:11 -0500)
committerEd Warnicke <eaw@cisco.com>
Wed, 15 May 2013 16:11:56 +0000 (11:11 -0500)
I'm intentionally breaking these up into small groups so they can
be reasonably reviewed, rather than one giant group that can't.
Contributes to fixing bug 20.

Second in the set.

Change-Id: I5bf19c2bdf33bfde391f30867b27f433fc971a30
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6StatsReply.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6StatsRequest.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Output.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/PushVlan.java

index f88efa36a53acaebf1dba5f9564e0c2b2edcf712..6893fa78e279979bb3149038a3f87b3bc4234a49 100644 (file)
@@ -12,9 +12,6 @@ package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6e
 import java.nio.ByteBuffer;
 import java.util.List;
 
 import java.nio.ByteBuffer;
 import java.util.List;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.openflow.protocol.action.OFAction;
 import org.openflow.protocol.statistics.OFVendorStatistics;
 import org.openflow.util.U16;
 import org.openflow.protocol.action.OFAction;
 import org.openflow.protocol.statistics.OFVendorStatistics;
 import org.openflow.util.U16;
index 26d0065a45162ca493a5c15266d4b405ecc338ab..593b464d3c68cec4f3a753657c3085a9081b94bf 100644 (file)
@@ -9,11 +9,10 @@
 
 package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
 
 
 package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
+import java.nio.ByteBuffer;
+
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.openflow.protocol.statistics.OFVendorStatistics;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.openflow.protocol.statistics.OFVendorStatistics;
-import java.nio.ByteBuffer;
 
 
 /**
 
 
 /**
@@ -140,7 +139,13 @@ public class V6StatsRequest extends OFVendorStatistics {
 
     @Override
     public int hashCode() {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + match_len;
+        result = prime * result + msgsubtype;
+        result = prime * result + outPort;
+        result = prime * result + tableId;
+        return result;
     }
 
     @Override
     }
 
     @Override
@@ -151,6 +156,21 @@ public class V6StatsRequest extends OFVendorStatistics {
 
     @Override
     public boolean equals(Object obj) {
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        V6StatsRequest other = (V6StatsRequest) obj;
+        if (match_len != other.match_len)
+            return false;
+        if (msgsubtype != other.msgsubtype)
+            return false;
+        if (outPort != other.outPort)
+            return false;
+        if (tableId != other.tableId)
+            return false;
+        return true;
     }
 }
     }
 }
index 5e4f5f81fa15ef92d044324c667f97c7ddbffccd..d8144d7bb74eaaf7a043ce3cba623b58b53c041b 100644 (file)
@@ -15,8 +15,6 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlTransient;
 
 import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlTransient;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -122,12 +120,24 @@ public abstract class Action {
 
     @Override
     public int hashCode() {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((type == null) ? 0 : type.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Action other = (Action) obj;
+        if (type != other.type)
+            return false;
+        return true;
     }
 
     @Override
     }
 
     @Override
index 8c23da8cfa2c80bf79d71296de60ff0b9d68d2f4..e09968836ff1877cfb195974808aaceda1ef4680 100644 (file)
@@ -14,8 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.core.NodeConnector;
 
 /**
 import org.opendaylight.controller.sal.core.NodeConnector;
 
 /**
@@ -46,13 +44,28 @@ public class Output extends Action {
     }
 
     @Override
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Output other = (Output) obj;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        return result;
     }
 
     @Override
     }
 
     @Override
index d50851ae49705df37bf61c5f143c3cdc7d87051d..f3b862fe7e2d2e16e5a5e07da4afa992d0478a6a 100644 (file)
@@ -14,8 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 
 /**
 import org.opendaylight.controller.sal.utils.EtherTypes;
 
 /**
@@ -147,13 +145,34 @@ public class PushVlan extends Action {
     }
 
     @Override
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        PushVlan other = (PushVlan) obj;
+        if (cfi != other.cfi)
+            return false;
+        if (pcp != other.pcp)
+            return false;
+        if (tag != other.tag)
+            return false;
+        if (vlanId != other.vlanId)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + cfi;
+        result = prime * result + pcp;
+        result = prime * result + tag;
+        result = prime * result + vlanId;
+        return result;
     }
 
     @Override
     }
 
     @Override