Statistics Mgr to avoid unnucessary cache updates
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / reader / NodeTableStatistics.java
1 /*
2  * Copyright (c) 2013 Big Switch Networks, Inc.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.reader;
9
10 import java.io.Serializable;
11
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlElement;
15 import javax.xml.bind.annotation.XmlRootElement;
16
17 import org.opendaylight.controller.sal.core.NodeTable;
18
19 /**
20  * @author Aditya Prakash Vaja <aditya.vaja@bigswitch.com>
21  * Represents the Table statistics for the node
22  *
23  */
24
25 @XmlRootElement
26 @XmlAccessorType(XmlAccessType.NONE)
27 public class NodeTableStatistics implements Serializable {
28     private static final long serialVersionUID = 1L;
29
30     @XmlElement
31     private NodeTable nodeTable;
32     @XmlElement
33     private String name;
34     @XmlElement
35     private int activeCount;
36     @XmlElement
37     private long lookupCount;
38     @XmlElement
39     private long matchedCount;
40
41
42     @Override
43     public int hashCode() {
44         final int prime = 31;
45         int result = 1;
46         result = prime * result + activeCount;
47         result = prime * result + (int) (lookupCount ^ (lookupCount >>> 32));
48         result = prime * result + (int) (matchedCount ^ (matchedCount >>> 32));
49         result = prime * result + ((name == null) ? 0 : name.hashCode());
50         result = prime * result + ((nodeTable == null) ? 0 : nodeTable.hashCode());
51         return result;
52     }
53
54     @Override
55     public boolean equals(Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (obj == null) {
60             return false;
61         }
62         if (!(obj instanceof NodeTableStatistics)) {
63             return false;
64         }
65         NodeTableStatistics other = (NodeTableStatistics) obj;
66         if (activeCount != other.activeCount) {
67             return false;
68         }
69         if (lookupCount != other.lookupCount) {
70             return false;
71         }
72         if (matchedCount != other.matchedCount) {
73             return false;
74         }
75         if (name == null) {
76             if (other.name != null) {
77                 return false;
78             }
79         } else if (!name.equals(other.name)) {
80             return false;
81         }
82         if (nodeTable == null) {
83             if (other.nodeTable != null) {
84                 return false;
85             }
86         } else if (!nodeTable.equals(other.nodeTable)) {
87             return false;
88         }
89         return true;
90     }
91
92     //To Satisfy JAXB
93     public NodeTableStatistics() {
94
95     }
96
97     /**
98      * @return the node table
99      */
100     public NodeTable getNodeTable() {
101         return nodeTable;
102     }
103
104     /**
105      * @param table of the node
106      */
107     public void setNodeTable(NodeTable table) {
108         this.nodeTable = table;
109     }
110
111     /**
112      * @return name of the table
113      */
114     public String getName() {
115         return name;
116     }
117
118     /**
119      * @param name - set the table name to name
120      */
121     public void setName(String name) {
122         this.name = name;
123     }
124
125     /**
126      * @return the activeCount
127      */
128     public int getActiveCount() {
129         return activeCount;
130     }
131
132     /**
133      * @param activeCount the activeCount to set
134      */
135     public void setActiveCount(int activeCount) {
136         this.activeCount = activeCount;
137     }
138
139     /**
140      * @return the lookupCount
141      */
142     public long getLookupCount() {
143         return lookupCount;
144     }
145
146     /**
147      * @param lookupCount the lookupCount to set
148      */
149     public void setLookupCount(long lookupCount) {
150         this.lookupCount = lookupCount;
151     }
152
153     /**
154      * @return the matchedCount
155      */
156     public long getMatchedCount() {
157         return matchedCount;
158     }
159
160     /**
161      * @param matchedCount the matchedCount to set
162      */
163     public void setMatchedCount(long matchedCount) {
164         this.matchedCount = matchedCount;
165     }
166
167     @Override
168     public String toString() {
169         return "NodeTableStats[tableId = " + nodeTable
170                 + ", activeCount = " + activeCount
171                 + ", lookupCount = " + lookupCount
172                 + ", matchedCount = " + matchedCount + "]";
173     }
174 }