Replace EqualsBuilder and HashCodeBuilder in transient member case. 49/349/1
authorEd Warnicke <eaw@cisco.com>
Wed, 15 May 2013 15:55:16 +0000 (10:55 -0500)
committerEd Warnicke <eaw@cisco.com>
Wed, 15 May 2013 15:56:40 +0000 (10:56 -0500)
This partially addresses bug 20, and provides the example of the
case where we have transient member.  I'm breaking it out
so that the transient member case can be reviewed simply.

Change-Id: Ic05c3d6daa7e9412e195578336ed95a5d71671d8
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteConfig.java

index 706c29e..262c017 100644 (file)
@@ -18,8 +18,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.utils.GUIField;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
@@ -328,12 +326,40 @@ public class StaticRouteConfig implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((nextHop == null) ? 0 : nextHop.hashCode());
+        result = prime * result
+                + ((staticRoute == null) ? 0 : staticRoute.hashCode());
+        return result;
     }
 
     @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;
+        StaticRouteConfig other = (StaticRouteConfig) obj;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (nextHop == null) {
+            if (other.nextHop != null)
+                return false;
+        } else if (!nextHop.equals(other.nextHop))
+            return false;
+        if (staticRoute == null) {
+            if (other.staticRoute != null)
+                return false;
+        } else if (!staticRoute.equals(other.staticRoute))
+            return false;
+        return true;
     }
 
     @Override