blob: 4affdbdfe8be43168cf995de2b60b8cbc0651d4a [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2// Copyright (c) 2011, 2012 Open Networking Foundation
3// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4// This library was generated by the LoxiGen Compiler.
5// See the file LICENSE.txt which should have been included in the source distribution
6
7// Automatically generated by LOXI from template of_class.java
8// Do not modify
9
10package org.projectfloodlight.openflow.protocol.ver13;
11
12import org.projectfloodlight.openflow.protocol.*;
13import org.projectfloodlight.openflow.protocol.action.*;
14import org.projectfloodlight.openflow.protocol.actionid.*;
15import org.projectfloodlight.openflow.protocol.bsntlv.*;
16import org.projectfloodlight.openflow.protocol.errormsg.*;
17import org.projectfloodlight.openflow.protocol.meterband.*;
18import org.projectfloodlight.openflow.protocol.instruction.*;
19import org.projectfloodlight.openflow.protocol.instructionid.*;
20import org.projectfloodlight.openflow.protocol.match.*;
21import org.projectfloodlight.openflow.protocol.oxm.*;
22import org.projectfloodlight.openflow.protocol.queueprop.*;
23import org.projectfloodlight.openflow.types.*;
24import org.projectfloodlight.openflow.util.*;
25import org.projectfloodlight.openflow.exceptions.*;
26import org.slf4j.Logger;
27import org.slf4j.LoggerFactory;
28import java.util.Set;
29import org.jboss.netty.buffer.ChannelBuffer;
30import com.google.common.hash.PrimitiveSink;
31import com.google.common.hash.Funnel;
32
33class OFBucketCounterVer13 implements OFBucketCounter {
34 private static final Logger logger = LoggerFactory.getLogger(OFBucketCounterVer13.class);
35 // version: 1.3
36 final static byte WIRE_VERSION = 4;
37 final static int LENGTH = 16;
38
39 private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
40 private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
41
42 // OF message fields
43 private final U64 packetCount;
44 private final U64 byteCount;
45//
46 // Immutable default instance
47 final static OFBucketCounterVer13 DEFAULT = new OFBucketCounterVer13(
48 DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT
49 );
50
51 // package private constructor - used by readers, builders, and factory
52 OFBucketCounterVer13(U64 packetCount, U64 byteCount) {
53 this.packetCount = packetCount;
54 this.byteCount = byteCount;
55 }
56
57 // Accessors for OF message fields
58 @Override
59 public U64 getPacketCount() {
60 return packetCount;
61 }
62
63 @Override
64 public U64 getByteCount() {
65 return byteCount;
66 }
67
68 @Override
69 public OFVersion getVersion() {
70 return OFVersion.OF_13;
71 }
72
73
74
75 public OFBucketCounter.Builder createBuilder() {
76 return new BuilderWithParent(this);
77 }
78
79 static class BuilderWithParent implements OFBucketCounter.Builder {
80 final OFBucketCounterVer13 parentMessage;
81
82 // OF message fields
83 private boolean packetCountSet;
84 private U64 packetCount;
85 private boolean byteCountSet;
86 private U64 byteCount;
87
88 BuilderWithParent(OFBucketCounterVer13 parentMessage) {
89 this.parentMessage = parentMessage;
90 }
91
92 @Override
93 public U64 getPacketCount() {
94 return packetCount;
95 }
96
97 @Override
98 public OFBucketCounter.Builder setPacketCount(U64 packetCount) {
99 this.packetCount = packetCount;
100 this.packetCountSet = true;
101 return this;
102 }
103 @Override
104 public U64 getByteCount() {
105 return byteCount;
106 }
107
108 @Override
109 public OFBucketCounter.Builder setByteCount(U64 byteCount) {
110 this.byteCount = byteCount;
111 this.byteCountSet = true;
112 return this;
113 }
114 @Override
115 public OFVersion getVersion() {
116 return OFVersion.OF_13;
117 }
118
119
120
121 @Override
122 public OFBucketCounter build() {
123 U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
124 if(packetCount == null)
125 throw new NullPointerException("Property packetCount must not be null");
126 U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
127 if(byteCount == null)
128 throw new NullPointerException("Property byteCount must not be null");
129
130 //
131 return new OFBucketCounterVer13(
132 packetCount,
133 byteCount
134 );
135 }
136
137 }
138
139 static class Builder implements OFBucketCounter.Builder {
140 // OF message fields
141 private boolean packetCountSet;
142 private U64 packetCount;
143 private boolean byteCountSet;
144 private U64 byteCount;
145
146 @Override
147 public U64 getPacketCount() {
148 return packetCount;
149 }
150
151 @Override
152 public OFBucketCounter.Builder setPacketCount(U64 packetCount) {
153 this.packetCount = packetCount;
154 this.packetCountSet = true;
155 return this;
156 }
157 @Override
158 public U64 getByteCount() {
159 return byteCount;
160 }
161
162 @Override
163 public OFBucketCounter.Builder setByteCount(U64 byteCount) {
164 this.byteCount = byteCount;
165 this.byteCountSet = true;
166 return this;
167 }
168 @Override
169 public OFVersion getVersion() {
170 return OFVersion.OF_13;
171 }
172
173//
174 @Override
175 public OFBucketCounter build() {
176 U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
177 if(packetCount == null)
178 throw new NullPointerException("Property packetCount must not be null");
179 U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
180 if(byteCount == null)
181 throw new NullPointerException("Property byteCount must not be null");
182
183
184 return new OFBucketCounterVer13(
185 packetCount,
186 byteCount
187 );
188 }
189
190 }
191
192
193 final static Reader READER = new Reader();
194 static class Reader implements OFMessageReader<OFBucketCounter> {
195 @Override
196 public OFBucketCounter readFrom(ChannelBuffer bb) throws OFParseError {
197 U64 packetCount = U64.ofRaw(bb.readLong());
198 U64 byteCount = U64.ofRaw(bb.readLong());
199
200 OFBucketCounterVer13 bucketCounterVer13 = new OFBucketCounterVer13(
201 packetCount,
202 byteCount
203 );
204 if(logger.isTraceEnabled())
205 logger.trace("readFrom - read={}", bucketCounterVer13);
206 return bucketCounterVer13;
207 }
208 }
209
210 public void putTo(PrimitiveSink sink) {
211 FUNNEL.funnel(this, sink);
212 }
213
214 final static OFBucketCounterVer13Funnel FUNNEL = new OFBucketCounterVer13Funnel();
215 static class OFBucketCounterVer13Funnel implements Funnel<OFBucketCounterVer13> {
216 private static final long serialVersionUID = 1L;
217 @Override
218 public void funnel(OFBucketCounterVer13 message, PrimitiveSink sink) {
219 message.packetCount.putTo(sink);
220 message.byteCount.putTo(sink);
221 }
222 }
223
224
225 public void writeTo(ChannelBuffer bb) {
226 WRITER.write(bb, this);
227 }
228
229 final static Writer WRITER = new Writer();
230 static class Writer implements OFMessageWriter<OFBucketCounterVer13> {
231 @Override
232 public void write(ChannelBuffer bb, OFBucketCounterVer13 message) {
233 bb.writeLong(message.packetCount.getValue());
234 bb.writeLong(message.byteCount.getValue());
235
236
237 }
238 }
239
240 @Override
241 public String toString() {
242 StringBuilder b = new StringBuilder("OFBucketCounterVer13(");
243 b.append("packetCount=").append(packetCount);
244 b.append(", ");
245 b.append("byteCount=").append(byteCount);
246 b.append(")");
247 return b.toString();
248 }
249
250 @Override
251 public boolean equals(Object obj) {
252 if (this == obj)
253 return true;
254 if (obj == null)
255 return false;
256 if (getClass() != obj.getClass())
257 return false;
258 OFBucketCounterVer13 other = (OFBucketCounterVer13) obj;
259
260 if (packetCount == null) {
261 if (other.packetCount != null)
262 return false;
263 } else if (!packetCount.equals(other.packetCount))
264 return false;
265 if (byteCount == null) {
266 if (other.byteCount != null)
267 return false;
268 } else if (!byteCount.equals(other.byteCount))
269 return false;
270 return true;
271 }
272
273 @Override
274 public int hashCode() {
275 final int prime = 31;
276 int result = 1;
277
278 result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
279 result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
280 return result;
281 }
282
283}