alshabib | 86ac11c | 2014-08-14 16:14:41 -0700 | [diff] [blame^] | 1 | // 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 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver13; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; |
| 28 | import java.util.Set; |
| 29 | import org.jboss.netty.buffer.ChannelBuffer; |
| 30 | import com.google.common.hash.PrimitiveSink; |
| 31 | import com.google.common.hash.Funnel; |
| 32 | |
| 33 | class OFMeterFeaturesVer13 implements OFMeterFeatures { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFMeterFeaturesVer13.class); |
| 35 | // version: 1.3 |
| 36 | final static byte WIRE_VERSION = 4; |
| 37 | final static int LENGTH = 16; |
| 38 | |
| 39 | private final static long DEFAULT_MAX_METER = 0x0L; |
| 40 | private final static long DEFAULT_BAND_TYPES = 0x0L; |
| 41 | private final static long DEFAULT_CAPABILITIES = 0x0L; |
| 42 | private final static short DEFAULT_MAX_BANDS = (short) 0x0; |
| 43 | private final static short DEFAULT_MAX_COLOR = (short) 0x0; |
| 44 | |
| 45 | // OF message fields |
| 46 | private final long maxMeter; |
| 47 | private final long bandTypes; |
| 48 | private final long capabilities; |
| 49 | private final short maxBands; |
| 50 | private final short maxColor; |
| 51 | // |
| 52 | // Immutable default instance |
| 53 | final static OFMeterFeaturesVer13 DEFAULT = new OFMeterFeaturesVer13( |
| 54 | DEFAULT_MAX_METER, DEFAULT_BAND_TYPES, DEFAULT_CAPABILITIES, DEFAULT_MAX_BANDS, DEFAULT_MAX_COLOR |
| 55 | ); |
| 56 | |
| 57 | // package private constructor - used by readers, builders, and factory |
| 58 | OFMeterFeaturesVer13(long maxMeter, long bandTypes, long capabilities, short maxBands, short maxColor) { |
| 59 | this.maxMeter = maxMeter; |
| 60 | this.bandTypes = bandTypes; |
| 61 | this.capabilities = capabilities; |
| 62 | this.maxBands = maxBands; |
| 63 | this.maxColor = maxColor; |
| 64 | } |
| 65 | |
| 66 | // Accessors for OF message fields |
| 67 | @Override |
| 68 | public long getMaxMeter() { |
| 69 | return maxMeter; |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public long getBandTypes() { |
| 74 | return bandTypes; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public long getCapabilities() { |
| 79 | return capabilities; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public short getMaxBands() { |
| 84 | return maxBands; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public short getMaxColor() { |
| 89 | return maxColor; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public OFVersion getVersion() { |
| 94 | return OFVersion.OF_13; |
| 95 | } |
| 96 | |
| 97 | |
| 98 | |
| 99 | public OFMeterFeatures.Builder createBuilder() { |
| 100 | return new BuilderWithParent(this); |
| 101 | } |
| 102 | |
| 103 | static class BuilderWithParent implements OFMeterFeatures.Builder { |
| 104 | final OFMeterFeaturesVer13 parentMessage; |
| 105 | |
| 106 | // OF message fields |
| 107 | private boolean maxMeterSet; |
| 108 | private long maxMeter; |
| 109 | private boolean bandTypesSet; |
| 110 | private long bandTypes; |
| 111 | private boolean capabilitiesSet; |
| 112 | private long capabilities; |
| 113 | private boolean maxBandsSet; |
| 114 | private short maxBands; |
| 115 | private boolean maxColorSet; |
| 116 | private short maxColor; |
| 117 | |
| 118 | BuilderWithParent(OFMeterFeaturesVer13 parentMessage) { |
| 119 | this.parentMessage = parentMessage; |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public long getMaxMeter() { |
| 124 | return maxMeter; |
| 125 | } |
| 126 | |
| 127 | @Override |
| 128 | public OFMeterFeatures.Builder setMaxMeter(long maxMeter) { |
| 129 | this.maxMeter = maxMeter; |
| 130 | this.maxMeterSet = true; |
| 131 | return this; |
| 132 | } |
| 133 | @Override |
| 134 | public long getBandTypes() { |
| 135 | return bandTypes; |
| 136 | } |
| 137 | |
| 138 | @Override |
| 139 | public OFMeterFeatures.Builder setBandTypes(long bandTypes) { |
| 140 | this.bandTypes = bandTypes; |
| 141 | this.bandTypesSet = true; |
| 142 | return this; |
| 143 | } |
| 144 | @Override |
| 145 | public long getCapabilities() { |
| 146 | return capabilities; |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public OFMeterFeatures.Builder setCapabilities(long capabilities) { |
| 151 | this.capabilities = capabilities; |
| 152 | this.capabilitiesSet = true; |
| 153 | return this; |
| 154 | } |
| 155 | @Override |
| 156 | public short getMaxBands() { |
| 157 | return maxBands; |
| 158 | } |
| 159 | |
| 160 | @Override |
| 161 | public OFMeterFeatures.Builder setMaxBands(short maxBands) { |
| 162 | this.maxBands = maxBands; |
| 163 | this.maxBandsSet = true; |
| 164 | return this; |
| 165 | } |
| 166 | @Override |
| 167 | public short getMaxColor() { |
| 168 | return maxColor; |
| 169 | } |
| 170 | |
| 171 | @Override |
| 172 | public OFMeterFeatures.Builder setMaxColor(short maxColor) { |
| 173 | this.maxColor = maxColor; |
| 174 | this.maxColorSet = true; |
| 175 | return this; |
| 176 | } |
| 177 | @Override |
| 178 | public OFVersion getVersion() { |
| 179 | return OFVersion.OF_13; |
| 180 | } |
| 181 | |
| 182 | |
| 183 | |
| 184 | @Override |
| 185 | public OFMeterFeatures build() { |
| 186 | long maxMeter = this.maxMeterSet ? this.maxMeter : parentMessage.maxMeter; |
| 187 | long bandTypes = this.bandTypesSet ? this.bandTypes : parentMessage.bandTypes; |
| 188 | long capabilities = this.capabilitiesSet ? this.capabilities : parentMessage.capabilities; |
| 189 | short maxBands = this.maxBandsSet ? this.maxBands : parentMessage.maxBands; |
| 190 | short maxColor = this.maxColorSet ? this.maxColor : parentMessage.maxColor; |
| 191 | |
| 192 | // |
| 193 | return new OFMeterFeaturesVer13( |
| 194 | maxMeter, |
| 195 | bandTypes, |
| 196 | capabilities, |
| 197 | maxBands, |
| 198 | maxColor |
| 199 | ); |
| 200 | } |
| 201 | |
| 202 | } |
| 203 | |
| 204 | static class Builder implements OFMeterFeatures.Builder { |
| 205 | // OF message fields |
| 206 | private boolean maxMeterSet; |
| 207 | private long maxMeter; |
| 208 | private boolean bandTypesSet; |
| 209 | private long bandTypes; |
| 210 | private boolean capabilitiesSet; |
| 211 | private long capabilities; |
| 212 | private boolean maxBandsSet; |
| 213 | private short maxBands; |
| 214 | private boolean maxColorSet; |
| 215 | private short maxColor; |
| 216 | |
| 217 | @Override |
| 218 | public long getMaxMeter() { |
| 219 | return maxMeter; |
| 220 | } |
| 221 | |
| 222 | @Override |
| 223 | public OFMeterFeatures.Builder setMaxMeter(long maxMeter) { |
| 224 | this.maxMeter = maxMeter; |
| 225 | this.maxMeterSet = true; |
| 226 | return this; |
| 227 | } |
| 228 | @Override |
| 229 | public long getBandTypes() { |
| 230 | return bandTypes; |
| 231 | } |
| 232 | |
| 233 | @Override |
| 234 | public OFMeterFeatures.Builder setBandTypes(long bandTypes) { |
| 235 | this.bandTypes = bandTypes; |
| 236 | this.bandTypesSet = true; |
| 237 | return this; |
| 238 | } |
| 239 | @Override |
| 240 | public long getCapabilities() { |
| 241 | return capabilities; |
| 242 | } |
| 243 | |
| 244 | @Override |
| 245 | public OFMeterFeatures.Builder setCapabilities(long capabilities) { |
| 246 | this.capabilities = capabilities; |
| 247 | this.capabilitiesSet = true; |
| 248 | return this; |
| 249 | } |
| 250 | @Override |
| 251 | public short getMaxBands() { |
| 252 | return maxBands; |
| 253 | } |
| 254 | |
| 255 | @Override |
| 256 | public OFMeterFeatures.Builder setMaxBands(short maxBands) { |
| 257 | this.maxBands = maxBands; |
| 258 | this.maxBandsSet = true; |
| 259 | return this; |
| 260 | } |
| 261 | @Override |
| 262 | public short getMaxColor() { |
| 263 | return maxColor; |
| 264 | } |
| 265 | |
| 266 | @Override |
| 267 | public OFMeterFeatures.Builder setMaxColor(short maxColor) { |
| 268 | this.maxColor = maxColor; |
| 269 | this.maxColorSet = true; |
| 270 | return this; |
| 271 | } |
| 272 | @Override |
| 273 | public OFVersion getVersion() { |
| 274 | return OFVersion.OF_13; |
| 275 | } |
| 276 | |
| 277 | // |
| 278 | @Override |
| 279 | public OFMeterFeatures build() { |
| 280 | long maxMeter = this.maxMeterSet ? this.maxMeter : DEFAULT_MAX_METER; |
| 281 | long bandTypes = this.bandTypesSet ? this.bandTypes : DEFAULT_BAND_TYPES; |
| 282 | long capabilities = this.capabilitiesSet ? this.capabilities : DEFAULT_CAPABILITIES; |
| 283 | short maxBands = this.maxBandsSet ? this.maxBands : DEFAULT_MAX_BANDS; |
| 284 | short maxColor = this.maxColorSet ? this.maxColor : DEFAULT_MAX_COLOR; |
| 285 | |
| 286 | |
| 287 | return new OFMeterFeaturesVer13( |
| 288 | maxMeter, |
| 289 | bandTypes, |
| 290 | capabilities, |
| 291 | maxBands, |
| 292 | maxColor |
| 293 | ); |
| 294 | } |
| 295 | |
| 296 | } |
| 297 | |
| 298 | |
| 299 | final static Reader READER = new Reader(); |
| 300 | static class Reader implements OFMessageReader<OFMeterFeatures> { |
| 301 | @Override |
| 302 | public OFMeterFeatures readFrom(ChannelBuffer bb) throws OFParseError { |
| 303 | long maxMeter = U32.f(bb.readInt()); |
| 304 | long bandTypes = U32.f(bb.readInt()); |
| 305 | long capabilities = U32.f(bb.readInt()); |
| 306 | short maxBands = U8.f(bb.readByte()); |
| 307 | short maxColor = U8.f(bb.readByte()); |
| 308 | // pad: 2 bytes |
| 309 | bb.skipBytes(2); |
| 310 | |
| 311 | OFMeterFeaturesVer13 meterFeaturesVer13 = new OFMeterFeaturesVer13( |
| 312 | maxMeter, |
| 313 | bandTypes, |
| 314 | capabilities, |
| 315 | maxBands, |
| 316 | maxColor |
| 317 | ); |
| 318 | if(logger.isTraceEnabled()) |
| 319 | logger.trace("readFrom - read={}", meterFeaturesVer13); |
| 320 | return meterFeaturesVer13; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | public void putTo(PrimitiveSink sink) { |
| 325 | FUNNEL.funnel(this, sink); |
| 326 | } |
| 327 | |
| 328 | final static OFMeterFeaturesVer13Funnel FUNNEL = new OFMeterFeaturesVer13Funnel(); |
| 329 | static class OFMeterFeaturesVer13Funnel implements Funnel<OFMeterFeaturesVer13> { |
| 330 | private static final long serialVersionUID = 1L; |
| 331 | @Override |
| 332 | public void funnel(OFMeterFeaturesVer13 message, PrimitiveSink sink) { |
| 333 | sink.putLong(message.maxMeter); |
| 334 | sink.putLong(message.bandTypes); |
| 335 | sink.putLong(message.capabilities); |
| 336 | sink.putShort(message.maxBands); |
| 337 | sink.putShort(message.maxColor); |
| 338 | // skip pad (2 bytes) |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | |
| 343 | public void writeTo(ChannelBuffer bb) { |
| 344 | WRITER.write(bb, this); |
| 345 | } |
| 346 | |
| 347 | final static Writer WRITER = new Writer(); |
| 348 | static class Writer implements OFMessageWriter<OFMeterFeaturesVer13> { |
| 349 | @Override |
| 350 | public void write(ChannelBuffer bb, OFMeterFeaturesVer13 message) { |
| 351 | bb.writeInt(U32.t(message.maxMeter)); |
| 352 | bb.writeInt(U32.t(message.bandTypes)); |
| 353 | bb.writeInt(U32.t(message.capabilities)); |
| 354 | bb.writeByte(U8.t(message.maxBands)); |
| 355 | bb.writeByte(U8.t(message.maxColor)); |
| 356 | // pad: 2 bytes |
| 357 | bb.writeZero(2); |
| 358 | |
| 359 | |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | @Override |
| 364 | public String toString() { |
| 365 | StringBuilder b = new StringBuilder("OFMeterFeaturesVer13("); |
| 366 | b.append("maxMeter=").append(maxMeter); |
| 367 | b.append(", "); |
| 368 | b.append("bandTypes=").append(bandTypes); |
| 369 | b.append(", "); |
| 370 | b.append("capabilities=").append(capabilities); |
| 371 | b.append(", "); |
| 372 | b.append("maxBands=").append(maxBands); |
| 373 | b.append(", "); |
| 374 | b.append("maxColor=").append(maxColor); |
| 375 | b.append(")"); |
| 376 | return b.toString(); |
| 377 | } |
| 378 | |
| 379 | @Override |
| 380 | public boolean equals(Object obj) { |
| 381 | if (this == obj) |
| 382 | return true; |
| 383 | if (obj == null) |
| 384 | return false; |
| 385 | if (getClass() != obj.getClass()) |
| 386 | return false; |
| 387 | OFMeterFeaturesVer13 other = (OFMeterFeaturesVer13) obj; |
| 388 | |
| 389 | if( maxMeter != other.maxMeter) |
| 390 | return false; |
| 391 | if( bandTypes != other.bandTypes) |
| 392 | return false; |
| 393 | if( capabilities != other.capabilities) |
| 394 | return false; |
| 395 | if( maxBands != other.maxBands) |
| 396 | return false; |
| 397 | if( maxColor != other.maxColor) |
| 398 | return false; |
| 399 | return true; |
| 400 | } |
| 401 | |
| 402 | @Override |
| 403 | public int hashCode() { |
| 404 | final int prime = 31; |
| 405 | int result = 1; |
| 406 | |
| 407 | result = prime * (int) (maxMeter ^ (maxMeter >>> 32)); |
| 408 | result = prime * (int) (bandTypes ^ (bandTypes >>> 32)); |
| 409 | result = prime * (int) (capabilities ^ (capabilities >>> 32)); |
| 410 | result = prime * result + maxBands; |
| 411 | result = prime * result + maxColor; |
| 412 | return result; |
| 413 | } |
| 414 | |
| 415 | } |