Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / reader / FlowOnNode.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.reader;
11
12 import java.io.Serializable;
13
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
18
19 import org.opendaylight.controller.sal.flowprogrammer.Flow;
20
21 /**
22  * Represents the flow that is installed on the network node
23  * along with the table location, hit counters and timers
24  */
25
26 @XmlRootElement (name="FlowStat")
27 @XmlAccessorType(XmlAccessType.NONE)
28 @Deprecated
29 public class FlowOnNode implements Serializable{
30     private static final long serialVersionUID = 1L;
31
32     @XmlElement
33     private Flow flow; // Flow descriptor
34     @XmlElement
35     private byte tableId;
36     @XmlElement
37     private int durationSeconds;
38     @XmlElement
39     private int durationNanoseconds;
40     @XmlElement
41     private long packetCount;
42     @XmlElement
43     private long byteCount;
44
45     /* Dummy constructor for JAXB */
46     @SuppressWarnings("unused")
47     private FlowOnNode () {
48     }
49
50     public FlowOnNode(Flow flow) {
51         this.flow = flow;
52     }
53
54     /**
55      * Returns the description of the flow which statistics are about
56      * @return
57      */
58     public Flow getFlow() {
59         return flow;
60     }
61
62     /**
63      * Set the packet count's value
64      * @param count
65      */
66     public void setPacketCount(long count) {
67         packetCount = count;
68     }
69
70     /**
71      * Set the byte count's value
72      * @param count
73      */
74     public void setByteCount(long count) {
75         byteCount = count;
76     }
77
78     /**
79      * Returns the packet count for the flow
80      * @return
81      */
82     public long getPacketCount() {
83         return packetCount;
84     }
85
86     /**
87      * Return the byte count for the flow
88      * @return
89      */
90     public long getByteCount() {
91         return byteCount;
92     }
93
94     public byte getTableId() {
95         return tableId;
96     }
97
98     public void setTableId(byte tableId) {
99         this.tableId = tableId;
100     }
101
102     public int getDurationSeconds() {
103         return durationSeconds;
104     }
105
106     public void setDurationSeconds(int durationSeconds) {
107         this.durationSeconds = durationSeconds;
108     }
109
110     public int getDurationNanoseconds() {
111         return durationNanoseconds;
112     }
113
114     public void setDurationNanoseconds(int durationNanoseconds) {
115         this.durationNanoseconds = durationNanoseconds;
116     }
117
118     @Override
119     public int hashCode() {
120         final int prime = 31;
121         int result = 1;
122         result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
123         result = prime * result + durationNanoseconds;
124         result = prime * result + durationSeconds;
125         result = prime * result + ((flow == null) ? 0 : flow.hashCode());
126         result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
127         result = prime * result + tableId;
128         return result;
129     }
130
131     @Override
132     public boolean equals(Object obj) {
133         if (this == obj) {
134             return true;
135         }
136         if (obj == null) {
137             return false;
138         }
139         if (!(obj instanceof FlowOnNode)) {
140             return false;
141         }
142         FlowOnNode other = (FlowOnNode) obj;
143         if (byteCount != other.byteCount) {
144             return false;
145         }
146         if (durationNanoseconds != other.durationNanoseconds) {
147             return false;
148         }
149         if (durationSeconds != other.durationSeconds) {
150             return false;
151         }
152         if (flow == null) {
153             if (other.flow != null) {
154                 return false;
155             }
156         } else if (!flow.equals(other.flow)) {
157             return false;
158         }
159         if (packetCount != other.packetCount) {
160             return false;
161         }
162         if (tableId != other.tableId) {
163             return false;
164         }
165         return true;
166     }
167
168     @Override
169     public String toString() {
170         return "FlowOnNode[flow =" + flow + ", tableId = " + tableId
171                 + ", sec = " + durationSeconds + ", nsec = "
172                 + durationNanoseconds + ", pkt = " + packetCount + ", byte = "
173                 + byteCount + "]";
174     }
175 }