Statistics Mgr to avoid unnucessary cache updates
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / reader / NodeTableStatistics.java
index 3ccf8f59297701c0848bade6a9ef0a404a6ce6a0..7c404178cfc195edd206500c90ba4155c7e02f73 100644 (file)
@@ -7,6 +7,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;
@@ -17,12 +19,14 @@ import org.opendaylight.controller.sal.core.NodeTable;
 /**
  * @author Aditya Prakash Vaja <aditya.vaja@bigswitch.com>
  * Represents the Table statistics for the node
- * 
+ *
  */
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class NodeTableStatistics {
+public class NodeTableStatistics implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     @XmlElement
     private NodeTable nodeTable;
     @XmlElement
@@ -35,6 +39,56 @@ public class NodeTableStatistics {
     private long matchedCount;
 
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + activeCount;
+        result = prime * result + (int) (lookupCount ^ (lookupCount >>> 32));
+        result = prime * result + (int) (matchedCount ^ (matchedCount >>> 32));
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((nodeTable == null) ? 0 : nodeTable.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (!(obj instanceof NodeTableStatistics)) {
+            return false;
+        }
+        NodeTableStatistics other = (NodeTableStatistics) obj;
+        if (activeCount != other.activeCount) {
+            return false;
+        }
+        if (lookupCount != other.lookupCount) {
+            return false;
+        }
+        if (matchedCount != other.matchedCount) {
+            return false;
+        }
+        if (name == null) {
+            if (other.name != null) {
+                return false;
+            }
+        } else if (!name.equals(other.name)) {
+            return false;
+        }
+        if (nodeTable == null) {
+            if (other.nodeTable != null) {
+                return false;
+            }
+        } else if (!nodeTable.equals(other.nodeTable)) {
+            return false;
+        }
+        return true;
+    }
+
     //To Satisfy JAXB
     public NodeTableStatistics() {