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

Third in the set.

Change-Id: If8008c7e9db88022edd50fbc36f82cd32cdb6bad
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlDst.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlSrc.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlType.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwDst.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwSrc.java

index 53c2806443203f55dd47003d135ff1f4a5825094..2413c23314b5732c3e5d17cbbb44058835cb3d2d 100644 (file)
@@ -9,13 +9,13 @@
 
 package org.opendaylight.controller.sal.action;
 
+import java.util.Arrays;
+
 import javax.xml.bind.annotation.XmlAccessType;
 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;
 import org.opendaylight.controller.sal.utils.HexEncode;
 
 /**
@@ -52,13 +52,25 @@ public class SetDlDst 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;
+        SetDlDst other = (SetDlDst) obj;
+        if (!Arrays.equals(address, other.address))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + Arrays.hashCode(address);
+        return result;
     }
 
     @Override
index 9d31fe274e19fdb2157c1841c85b4511c5c0c95d..3cdd5b617038c9aadf5aad41115edfebc26ef768 100644 (file)
@@ -9,13 +9,13 @@
 
 package org.opendaylight.controller.sal.action;
 
+import java.util.Arrays;
+
 import javax.xml.bind.annotation.XmlAccessType;
 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;
 import org.opendaylight.controller.sal.utils.HexEncode;
 
 /**
@@ -56,13 +56,25 @@ public class SetDlSrc 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;
+        SetDlSrc other = (SetDlSrc) obj;
+        if (!Arrays.equals(address, other.address))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + Arrays.hashCode(address);
+        return result;
     }
 
     @Override
index 51a24a6ac2ecd1cff2374c72158df4217b7d462a..f76000c64948d42849fd4e5c1cde568e373dcf4b 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 org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 
 /**
@@ -55,13 +53,25 @@ public class SetDlType 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;
+        SetDlType other = (SetDlType) obj;
+        if (dlType != other.dlType)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + dlType;
+        return result;
     }
 
     @Override
index 7db7081ab967c64c480f3a913c961249bfeaaac2..bccca3f1f236b99aafee3a77d8803aad9111a284 100644 (file)
@@ -16,9 +16,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 destination address action
  */
@@ -53,13 +50,28 @@ public class SetNwDst 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;
+        SetNwDst other = (SetNwDst) obj;
+        if (address == null) {
+            if (other.address != null)
+                return false;
+        } else if (!address.equals(other.address))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((address == null) ? 0 : address.hashCode());
+        return result;
     }
 
     @Override
index 3e75e47502cae2710a8f5d16b351d0ffae5e283e..5595b610de6f153cd3fbea6b8e46039ceadfaaea 100644 (file)
@@ -16,9 +16,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 source address action
  */
@@ -53,13 +50,28 @@ public class SetNwSrc 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;
+        SetNwSrc other = (SetNwSrc) obj;
+        if (address == null) {
+            if (other.address != null)
+                return false;
+        } else if (!address.equals(other.address))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((address == null) ? 0 : address.hashCode());
+        return result;
     }
 
     @Override