eb33ad67995f2621fd95024c0736e897fb6f18ee
[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     @XmlElement
41     private int maximumEntries;
42
43
44     @Override
45     public int hashCode() {
46         final int prime = 31;
47         int result = 1;
48         result = prime * result + activeCount;
49         result = prime * result + (int) (lookupCount ^ (lookupCount >>> 32));
50         result = prime * result + (int) (matchedCount ^ (matchedCount >>> 32));
51         result = prime * result + ((name == null) ? 0 : name.hashCode());
52         result = prime * result + ((nodeTable == null) ? 0 : nodeTable.hashCode());
53         return result;
54     }
55
56     @Override
57     public boolean equals(Object obj) {
58         if (this == obj) {
59             return true;
60         }
61         if (obj == null) {
62             return false;
63         }
64         if (!(obj instanceof NodeTableStatistics)) {
65             return false;
66         }
67         NodeTableStatistics other = (NodeTableStatistics) obj;
68         if (activeCount != other.activeCount) {
69             return false;
70         }
71         if (lookupCount != other.lookupCount) {
72             return false;
73         }
74         if (matchedCount != other.matchedCount) {
75             return false;
76         }
77         if (name == null) {
78             if (other.name != null) {
79                 return false;
80             }
81         } else if (!name.equals(other.name)) {
82             return false;
83         }
84         if (nodeTable == null) {
85             if (other.nodeTable != null) {
86                 return false;
87             }
88         } else if (!nodeTable.equals(other.nodeTable)) {
89             return false;
90         }
91         return true;
92     }
93
94     //To Satisfy JAXB
95     public NodeTableStatistics() {
96
97     }
98
99     /**
100      * @return the node table
101      */
102     public NodeTable getNodeTable() {
103         return nodeTable;
104     }
105
106     /**
107      * @param table of the node
108      */
109     public void setNodeTable(NodeTable table) {
110         this.nodeTable = table;
111     }
112
113     /**
114      * @return name of the table
115      */
116     public String getName() {
117         return name;
118     }
119
120     /**
121      * @param name - set the table name to name
122      */
123     public void setName(String name) {
124         this.name = name;
125     }
126
127     /**
128      * @return the activeCount
129      */
130     public int getActiveCount() {
131         return activeCount;
132     }
133
134     /**
135      * @param activeCount the activeCount to set
136      */
137     public void setActiveCount(int activeCount) {
138         this.activeCount = activeCount;
139     }
140
141     /**
142      * @return the lookupCount
143      */
144     public long getLookupCount() {
145         return lookupCount;
146     }
147
148     /**
149      * @param lookupCount the lookupCount to set
150      */
151     public void setLookupCount(long lookupCount) {
152         this.lookupCount = lookupCount;
153     }
154
155     /**
156      * @return the matchedCount
157      */
158     public long getMatchedCount() {
159         return matchedCount;
160     }
161
162     /**
163      * @param matchedCount the matchedCount to set
164      */
165     public void setMatchedCount(long matchedCount) {
166         this.matchedCount = matchedCount;
167     }
168
169     /**
170      * @return the maximumEntries
171      */
172     public long getMaximumEntries() {
173         return maximumEntries;
174     }
175
176     /**
177      * @param maximumEntries the maximumEntries to set
178      */
179     public void setMaximumEntries(int maximumEntries) {
180         this.maximumEntries = maximumEntries;
181     }
182
183     @Override
184     public String toString() {
185         return "NodeTableStats[tableId = " + nodeTable
186                 + ", activeCount = " + activeCount
187                 + ", lookupCount = " + lookupCount
188                 + ", matchedCount = " + matchedCount + "]";
189     }
190 }