blob: 7f641e5d1f9b7cfe6906a7a4605ade9979736b47 [file] [log] [blame]
alshabib86ac11c2014-08-14 16:14:41 -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 OFMeterBandStatsVer13 implements OFMeterBandStats {
34 private static final Logger logger = LoggerFactory.getLogger(OFMeterBandStatsVer13.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_BAND_COUNT = U64.ZERO;
40 private final static U64 DEFAULT_BYTE_BAND_COUNT = U64.ZERO;
41
42 // OF message fields
43 private final U64 packetBandCount;
44 private final U64 byteBandCount;
45//
46 // Immutable default instance
47 final static OFMeterBandStatsVer13 DEFAULT = new OFMeterBandStatsVer13(
48 DEFAULT_PACKET_BAND_COUNT, DEFAULT_BYTE_BAND_COUNT
49 );
50
51 // package private constructor - used by readers, builders, and factory
52 OFMeterBandStatsVer13(U64 packetBandCount, U64 byteBandCount) {
53 this.packetBandCount = packetBandCount;
54 this.byteBandCount = byteBandCount;
55 }
56
57 // Accessors for OF message fields
58 @Override
59 public U64 getPacketBandCount() {
60 return packetBandCount;
61 }
62
63 @Override
64 public U64 getByteBandCount() {
65 return byteBandCount;
66 }
67
68 @Override
69 public OFVersion getVersion() {
70 return OFVersion.OF_13;
71 }
72
73
74
75 public OFMeterBandStats.Builder createBuilder() {
76 return new BuilderWithParent(this);
77 }
78
79 static class BuilderWithParent implements OFMeterBandStats.Builder {
80 final OFMeterBandStatsVer13 parentMessage;
81
82 // OF message fields
83 private boolean packetBandCountSet;
84 private U64 packetBandCount;
85 private boolean byteBandCountSet;
86 private U64 byteBandCount;
87
88 BuilderWithParent(OFMeterBandStatsVer13 parentMessage) {
89 this.parentMessage = parentMessage;
90 }
91
92 @Override
93 public U64 getPacketBandCount() {
94 return packetBandCount;
95 }
96
97 @Override
98 public OFMeterBandStats.Builder setPacketBandCount(U64 packetBandCount) {
99 this.packetBandCount = packetBandCount;
100 this.packetBandCountSet = true;
101 return this;
102 }
103 @Override
104 public U64 getByteBandCount() {
105 return byteBandCount;
106 }
107
108 @Override
109 public OFMeterBandStats.Builder setByteBandCount(U64 byteBandCount) {
110 this.byteBandCount = byteBandCount;
111 this.byteBandCountSet = true;
112 return this;
113 }
114 @Override
115 public OFVersion getVersion() {
116 return OFVersion.OF_13;
117 }
118
119
120
121 @Override
122 public OFMeterBandStats build() {
123 U64 packetBandCount = this.packetBandCountSet ? this.packetBandCount : parentMessage.packetBandCount;
124 if(packetBandCount == null)
125 throw new NullPointerException("Property packetBandCount must not be null");
126 U64 byteBandCount = this.byteBandCountSet ? this.byteBandCount : parentMessage.byteBandCount;
127 if(byteBandCount == null)
128 throw new NullPointerException("Property byteBandCount must not be null");
129
130 //
131 return new OFMeterBandStatsVer13(
132 packetBandCount,
133 byteBandCount
134 );
135 }
136
137 }
138
139 static class Builder implements OFMeterBandStats.Builder {
140 // OF message fields
141 private boolean packetBandCountSet;
142 private U64 packetBandCount;
143 private boolean byteBandCountSet;
144 private U64 byteBandCount;
145
146 @Override
147 public U64 getPacketBandCount() {
148 return packetBandCount;
149 }
150
151 @Override
152 public OFMeterBandStats.Builder setPacketBandCount(U64 packetBandCount) {
153 this.packetBandCount = packetBandCount;
154 this.packetBandCountSet = true;
155 return this;
156 }
157 @Override
158 public U64 getByteBandCount() {
159 return byteBandCount;
160 }
161
162 @Override
163 public OFMeterBandStats.Builder setByteBandCount(U64 byteBandCount) {
164 this.byteBandCount = byteBandCount;
165 this.byteBandCountSet = true;
166 return this;
167 }
168 @Override
169 public OFVersion getVersion() {
170 return OFVersion.OF_13;
171 }
172
173//
174 @Override
175 public OFMeterBandStats build() {
176 U64 packetBandCount = this.packetBandCountSet ? this.packetBandCount : DEFAULT_PACKET_BAND_COUNT;
177 if(packetBandCount == null)
178 throw new NullPointerException("Property packetBandCount must not be null");
179 U64 byteBandCount = this.byteBandCountSet ? this.byteBandCount : DEFAULT_BYTE_BAND_COUNT;
180 if(byteBandCount == null)
181 throw new NullPointerException("Property byteBandCount must not be null");
182
183
184 return new OFMeterBandStatsVer13(
185 packetBandCount,
186 byteBandCount
187 );
188 }
189
190 }
191
192
193 final static Reader READER = new Reader();
194 static class Reader implements OFMessageReader<OFMeterBandStats> {
195 @Override
196 public OFMeterBandStats readFrom(ChannelBuffer bb) throws OFParseError {
197 U64 packetBandCount = U64.ofRaw(bb.readLong());
198 U64 byteBandCount = U64.ofRaw(bb.readLong());
199
200 OFMeterBandStatsVer13 meterBandStatsVer13 = new OFMeterBandStatsVer13(
201 packetBandCount,
202 byteBandCount
203 );
204 if(logger.isTraceEnabled())
205 logger.trace("readFrom - read={}", meterBandStatsVer13);
206 return meterBandStatsVer13;
207 }
208 }
209
210 public void putTo(PrimitiveSink sink) {
211 FUNNEL.funnel(this, sink);
212 }
213
214 final static OFMeterBandStatsVer13Funnel FUNNEL = new OFMeterBandStatsVer13Funnel();
215 static class OFMeterBandStatsVer13Funnel implements Funnel<OFMeterBandStatsVer13> {
216 private static final long serialVersionUID = 1L;
217 @Override
218 public void funnel(OFMeterBandStatsVer13 message, PrimitiveSink sink) {
219 message.packetBandCount.putTo(sink);
220 message.byteBandCount.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<OFMeterBandStatsVer13> {
231 @Override
232 public void write(ChannelBuffer bb, OFMeterBandStatsVer13 message) {
233 bb.writeLong(message.packetBandCount.getValue());
234 bb.writeLong(message.byteBandCount.getValue());
235
236
237 }
238 }
239
240 @Override
241 public String toString() {
242 StringBuilder b = new StringBuilder("OFMeterBandStatsVer13(");
243 b.append("packetBandCount=").append(packetBandCount);
244 b.append(", ");
245 b.append("byteBandCount=").append(byteBandCount);
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 OFMeterBandStatsVer13 other = (OFMeterBandStatsVer13) obj;
259
260 if (packetBandCount == null) {
261 if (other.packetBandCount != null)
262 return false;
263 } else if (!packetBandCount.equals(other.packetBandCount))
264 return false;
265 if (byteBandCount == null) {
266 if (other.byteBandCount != null)
267 return false;
268 } else if (!byteBandCount.equals(other.byteBandCount))
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 + ((packetBandCount == null) ? 0 : packetBandCount.hashCode());
279 result = prime * result + ((byteBandCount == null) ? 0 : byteBandCount.hashCode());
280 return result;
281 }
282
283}