Statistics Mgr to avoid unnucessary cache updates
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / reader / FlowOnNode.java
index fe93d1c985878dfad7f0c3d0d0e392530cbe8132..994ee4533e077ab3ad74e65f08306d10a9910320 100644 (file)
@@ -9,6 +9,8 @@
 
 package org.opendaylight.controller.sal.reader;
 
+import java.io.Serializable;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -23,7 +25,9 @@ import org.opendaylight.controller.sal.flowprogrammer.Flow;
 
 @XmlRootElement (name="FlowStat")
 @XmlAccessorType(XmlAccessType.NONE)
-public class FlowOnNode {
+public class FlowOnNode implements Serializable{
+    private static final long serialVersionUID = 1L;
+
     @XmlElement
     private Flow flow; // Flow descriptor
     @XmlElement
@@ -38,6 +42,7 @@ public class FlowOnNode {
     private long byteCount;
 
     /* Dummy constructor for JAXB */
+    @SuppressWarnings("unused")
     private FlowOnNode () {
     }
 
@@ -109,6 +114,56 @@ public class FlowOnNode {
         this.durationNanoseconds = durationNanoseconds;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
+        result = prime * result + durationNanoseconds;
+        result = prime * result + durationSeconds;
+        result = prime * result + ((flow == null) ? 0 : flow.hashCode());
+        result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
+        result = prime * result + tableId;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (!(obj instanceof FlowOnNode)) {
+            return false;
+        }
+        FlowOnNode other = (FlowOnNode) obj;
+        if (byteCount != other.byteCount) {
+            return false;
+        }
+        if (durationNanoseconds != other.durationNanoseconds) {
+            return false;
+        }
+        if (durationSeconds != other.durationSeconds) {
+            return false;
+        }
+        if (flow == null) {
+            if (other.flow != null) {
+                return false;
+            }
+        } else if (!flow.equals(other.flow)) {
+            return false;
+        }
+        if (packetCount != other.packetCount) {
+            return false;
+        }
+        if (tableId != other.tableId) {
+            return false;
+        }
+        return true;
+    }
+
     @Override
     public String toString() {
         return "FlowOnNode[flow =" + flow + ", tableId = " + tableId