Six more Equals/HashCode/StringBuilder replacements 53/353/1
authorEd Warnicke <eaw@cisco.com>
Wed, 15 May 2013 16:17:48 +0000 (11:17 -0500)
committerEd Warnicke <eaw@cisco.com>
Wed, 15 May 2013 16:17:48 +0000 (11:17 -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.

Fourth in set.

Change-Id: Ic24cd900b1b88a1496c5f0a14f8f24650c00b297
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwTos.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpDst.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpSrc.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanCfi.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanId.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanPcp.java

index 33c96d37385df0a31d36c5ac960e1805f8e789a6..69fdd89ffb4cfb10f12ae899498c007454511edf 100644 (file)
@@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 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;
-
 /**
  * Set network TOS action
  */
@@ -47,13 +44,25 @@ public class SetNwTos extends Action {
     }
 
     @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;
+        SetNwTos other = (SetNwTos) obj;
+        if (tos != other.tos)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + tos;
+        return result;
     }
 
     @Override
index fb7c824494fc3b1aca82859b81045adaa7e7e204..825092c54fe355b520d0098771142b662c265930 100644 (file)
@@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 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;
-
 /**
  * Set destination transport port action
  */
@@ -46,13 +43,25 @@ public class SetTpDst extends Action {
     }
 
     @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;
+        SetTpDst other = (SetTpDst) obj;
+        if (port != other.port)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + port;
+        return result;
     }
 
     @Override
index 20210ad5e846f1eb4dfaee76c9b4f1616f0c0cc4..cdae5aad2ac7385c300f9c0f1f43f6456fd73f7d 100644 (file)
@@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 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;
-
 /**
  * Set source transport port action
  *
@@ -47,13 +44,25 @@ public class SetTpSrc extends Action {
     }
 
     @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;
+        SetTpSrc other = (SetTpSrc) obj;
+        if (port != other.port)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + port;
+        return result;
     }
 
     @Override
index c21430e9e95803ab698f6edc6d18fbf99cc5c7a1..fc3d0a60ef2a742a3929f8d6f09490db2f3511ab 100644 (file)
@@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 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;
-
 /**
  * Set vlan CFI action
  *
@@ -47,13 +44,25 @@ public class SetVlanCfi extends Action {
     }
 
     @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;
+        SetVlanCfi other = (SetVlanCfi) obj;
+        if (cfi != other.cfi)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + cfi;
+        return result;
     }
 
     @Override
index 9c9b364b897d1e9d31a381dbf5aeb292337fdd3e..b1e4748bc3b4f9dd1426cd4958af319eabda5e23 100644 (file)
@@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 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;
-
 /**
  * Set vlan id action
  */
@@ -48,13 +45,25 @@ public class SetVlanId extends Action {
     }
 
     @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;
+        SetVlanId other = (SetVlanId) obj;
+        if (vlanId != other.vlanId)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + vlanId;
+        return result;
     }
 
     @Override
index 5c315debffc2a044eaadb9bf63609929498b3a41..c47723ebdf61021bde42532dfe45ac4e26584cee 100644 (file)
@@ -14,9 +14,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 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;
-
 /**
  * Set vlan PCP action
  */
@@ -46,13 +43,25 @@ public class SetVlanPcp extends Action {
     }
 
     @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;
+        SetVlanPcp other = (SetVlanPcp) obj;
+        if (pcp != other.pcp)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + pcp;
+        return result;
     }
 
     @Override