Five more Equals/HashCode/StringBuilder replacements
[controller.git] / opendaylight / forwardingrulesmanager / api / src / main / java / org / opendaylight / controller / forwardingrulesmanager / FlowEntryInstall.java
index dfe331ad5f8b0443a3c9c819130d6a5be434392a..18255bc021aeffbc4ee5b887d98b19065dd9d08a 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.controller.forwardingrulesmanager;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.Node;
 
@@ -28,6 +26,7 @@ public class FlowEntryInstall {
     private FlowEntry original;
     private ContainerFlow cFlow;
     private FlowEntry install;
+    transient private long requestId; // async request id
     transient private boolean deletePending;
 
     public FlowEntryInstall(FlowEntry original, ContainerFlow cFlow) {
@@ -36,16 +35,45 @@ public class FlowEntryInstall {
         this.install = (cFlow == null) ? original.clone() : original
                 .mergeWith(cFlow);
         deletePending = false;
+        requestId = 0;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((cFlow == null) ? 0 : cFlow.hashCode());
+        result = prime * result + ((install == null) ? 0 : install.hashCode());
+        result = prime * result
+                + ((original == null) ? 0 : original.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;
+        FlowEntryInstall other = (FlowEntryInstall) obj;
+        if (cFlow == null) {
+            if (other.cFlow != null)
+                return false;
+        } else if (!cFlow.equals(other.cFlow))
+            return false;
+        if (install == null) {
+            if (other.install != null)
+                return false;
+        } else if (!install.equals(other.install))
+            return false;
+        if (original == null) {
+            if (other.original != null)
+                return false;
+        } else if (!original.equals(other.original))
+            return false;
+        return true;
     }
 
     public String getFlowName() {
@@ -84,9 +112,17 @@ public class FlowEntryInstall {
         this.deletePending = true;
     }
 
+    public void setRequestId(long rid) {
+        this.requestId = rid;
+    }
+    
+    public long getRequestId() {
+        return requestId;
+    }
+
     @Override
     public String toString() {
-        return "[Install = " + install + " Original: " + original + " cFlow: "
-                + cFlow + "]";
+        return "[Install = " + install + " Original = " + original + " cFlow = "
+                + cFlow + " rid = " + requestId + "]";
     }
 }