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.List; |
| 29 | import com.google.common.collect.ImmutableList; |
| 30 | import java.util.Set; |
| 31 | import org.jboss.netty.buffer.ChannelBuffer; |
| 32 | import com.google.common.hash.PrimitiveSink; |
| 33 | import com.google.common.hash.Funnel; |
| 34 | |
| 35 | class OFBsnGentableEntryDescStatsEntryVer13 implements OFBsnGentableEntryDescStatsEntry { |
| 36 | private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryDescStatsEntryVer13.class); |
| 37 | // version: 1.3 |
| 38 | final static byte WIRE_VERSION = 4; |
| 39 | final static int MINIMUM_LENGTH = 20; |
| 40 | |
| 41 | private final static U128 DEFAULT_CHECKSUM = U128.ZERO; |
| 42 | private final static List<OFBsnTlv> DEFAULT_KEY = ImmutableList.<OFBsnTlv>of(); |
| 43 | private final static List<OFBsnTlv> DEFAULT_VALUE = ImmutableList.<OFBsnTlv>of(); |
| 44 | |
| 45 | // OF message fields |
| 46 | private final U128 checksum; |
| 47 | private final List<OFBsnTlv> key; |
| 48 | private final List<OFBsnTlv> value; |
| 49 | // |
| 50 | // Immutable default instance |
| 51 | final static OFBsnGentableEntryDescStatsEntryVer13 DEFAULT = new OFBsnGentableEntryDescStatsEntryVer13( |
| 52 | DEFAULT_CHECKSUM, DEFAULT_KEY, DEFAULT_VALUE |
| 53 | ); |
| 54 | |
| 55 | // package private constructor - used by readers, builders, and factory |
| 56 | OFBsnGentableEntryDescStatsEntryVer13(U128 checksum, List<OFBsnTlv> key, List<OFBsnTlv> value) { |
| 57 | this.checksum = checksum; |
| 58 | this.key = key; |
| 59 | this.value = value; |
| 60 | } |
| 61 | |
| 62 | // Accessors for OF message fields |
| 63 | @Override |
| 64 | public U128 getChecksum() { |
| 65 | return checksum; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public List<OFBsnTlv> getKey() { |
| 70 | return key; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public List<OFBsnTlv> getValue() { |
| 75 | return value; |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public OFVersion getVersion() { |
| 80 | return OFVersion.OF_13; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | |
| 85 | public OFBsnGentableEntryDescStatsEntry.Builder createBuilder() { |
| 86 | return new BuilderWithParent(this); |
| 87 | } |
| 88 | |
| 89 | static class BuilderWithParent implements OFBsnGentableEntryDescStatsEntry.Builder { |
| 90 | final OFBsnGentableEntryDescStatsEntryVer13 parentMessage; |
| 91 | |
| 92 | // OF message fields |
| 93 | private boolean checksumSet; |
| 94 | private U128 checksum; |
| 95 | private boolean keySet; |
| 96 | private List<OFBsnTlv> key; |
| 97 | private boolean valueSet; |
| 98 | private List<OFBsnTlv> value; |
| 99 | |
| 100 | BuilderWithParent(OFBsnGentableEntryDescStatsEntryVer13 parentMessage) { |
| 101 | this.parentMessage = parentMessage; |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public U128 getChecksum() { |
| 106 | return checksum; |
| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public OFBsnGentableEntryDescStatsEntry.Builder setChecksum(U128 checksum) { |
| 111 | this.checksum = checksum; |
| 112 | this.checksumSet = true; |
| 113 | return this; |
| 114 | } |
| 115 | @Override |
| 116 | public List<OFBsnTlv> getKey() { |
| 117 | return key; |
| 118 | } |
| 119 | |
| 120 | @Override |
| 121 | public OFBsnGentableEntryDescStatsEntry.Builder setKey(List<OFBsnTlv> key) { |
| 122 | this.key = key; |
| 123 | this.keySet = true; |
| 124 | return this; |
| 125 | } |
| 126 | @Override |
| 127 | public List<OFBsnTlv> getValue() { |
| 128 | return value; |
| 129 | } |
| 130 | |
| 131 | @Override |
| 132 | public OFBsnGentableEntryDescStatsEntry.Builder setValue(List<OFBsnTlv> value) { |
| 133 | this.value = value; |
| 134 | this.valueSet = true; |
| 135 | return this; |
| 136 | } |
| 137 | @Override |
| 138 | public OFVersion getVersion() { |
| 139 | return OFVersion.OF_13; |
| 140 | } |
| 141 | |
| 142 | |
| 143 | |
| 144 | @Override |
| 145 | public OFBsnGentableEntryDescStatsEntry build() { |
| 146 | U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum; |
| 147 | if(checksum == null) |
| 148 | throw new NullPointerException("Property checksum must not be null"); |
| 149 | List<OFBsnTlv> key = this.keySet ? this.key : parentMessage.key; |
| 150 | if(key == null) |
| 151 | throw new NullPointerException("Property key must not be null"); |
| 152 | List<OFBsnTlv> value = this.valueSet ? this.value : parentMessage.value; |
| 153 | if(value == null) |
| 154 | throw new NullPointerException("Property value must not be null"); |
| 155 | |
| 156 | // |
| 157 | return new OFBsnGentableEntryDescStatsEntryVer13( |
| 158 | checksum, |
| 159 | key, |
| 160 | value |
| 161 | ); |
| 162 | } |
| 163 | |
| 164 | } |
| 165 | |
| 166 | static class Builder implements OFBsnGentableEntryDescStatsEntry.Builder { |
| 167 | // OF message fields |
| 168 | private boolean checksumSet; |
| 169 | private U128 checksum; |
| 170 | private boolean keySet; |
| 171 | private List<OFBsnTlv> key; |
| 172 | private boolean valueSet; |
| 173 | private List<OFBsnTlv> value; |
| 174 | |
| 175 | @Override |
| 176 | public U128 getChecksum() { |
| 177 | return checksum; |
| 178 | } |
| 179 | |
| 180 | @Override |
| 181 | public OFBsnGentableEntryDescStatsEntry.Builder setChecksum(U128 checksum) { |
| 182 | this.checksum = checksum; |
| 183 | this.checksumSet = true; |
| 184 | return this; |
| 185 | } |
| 186 | @Override |
| 187 | public List<OFBsnTlv> getKey() { |
| 188 | return key; |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public OFBsnGentableEntryDescStatsEntry.Builder setKey(List<OFBsnTlv> key) { |
| 193 | this.key = key; |
| 194 | this.keySet = true; |
| 195 | return this; |
| 196 | } |
| 197 | @Override |
| 198 | public List<OFBsnTlv> getValue() { |
| 199 | return value; |
| 200 | } |
| 201 | |
| 202 | @Override |
| 203 | public OFBsnGentableEntryDescStatsEntry.Builder setValue(List<OFBsnTlv> value) { |
| 204 | this.value = value; |
| 205 | this.valueSet = true; |
| 206 | return this; |
| 207 | } |
| 208 | @Override |
| 209 | public OFVersion getVersion() { |
| 210 | return OFVersion.OF_13; |
| 211 | } |
| 212 | |
| 213 | // |
| 214 | @Override |
| 215 | public OFBsnGentableEntryDescStatsEntry build() { |
| 216 | U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM; |
| 217 | if(checksum == null) |
| 218 | throw new NullPointerException("Property checksum must not be null"); |
| 219 | List<OFBsnTlv> key = this.keySet ? this.key : DEFAULT_KEY; |
| 220 | if(key == null) |
| 221 | throw new NullPointerException("Property key must not be null"); |
| 222 | List<OFBsnTlv> value = this.valueSet ? this.value : DEFAULT_VALUE; |
| 223 | if(value == null) |
| 224 | throw new NullPointerException("Property value must not be null"); |
| 225 | |
| 226 | |
| 227 | return new OFBsnGentableEntryDescStatsEntryVer13( |
| 228 | checksum, |
| 229 | key, |
| 230 | value |
| 231 | ); |
| 232 | } |
| 233 | |
| 234 | } |
| 235 | |
| 236 | |
| 237 | final static Reader READER = new Reader(); |
| 238 | static class Reader implements OFMessageReader<OFBsnGentableEntryDescStatsEntry> { |
| 239 | @Override |
| 240 | public OFBsnGentableEntryDescStatsEntry readFrom(ChannelBuffer bb) throws OFParseError { |
| 241 | int start = bb.readerIndex(); |
| 242 | int length = U16.f(bb.readShort()); |
| 243 | if(length < MINIMUM_LENGTH) |
| 244 | throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); |
| 245 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 246 | // Buffer does not have all data yet |
| 247 | bb.readerIndex(start); |
| 248 | return null; |
| 249 | } |
| 250 | if(logger.isTraceEnabled()) |
| 251 | logger.trace("readFrom - length={}", length); |
| 252 | int keyLength = U16.f(bb.readShort()); |
| 253 | U128 checksum = U128.read16Bytes(bb); |
| 254 | List<OFBsnTlv> key = ChannelUtils.readList(bb, keyLength, OFBsnTlvVer13.READER); |
| 255 | List<OFBsnTlv> value = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnTlvVer13.READER); |
| 256 | |
| 257 | OFBsnGentableEntryDescStatsEntryVer13 bsnGentableEntryDescStatsEntryVer13 = new OFBsnGentableEntryDescStatsEntryVer13( |
| 258 | checksum, |
| 259 | key, |
| 260 | value |
| 261 | ); |
| 262 | if(logger.isTraceEnabled()) |
| 263 | logger.trace("readFrom - read={}", bsnGentableEntryDescStatsEntryVer13); |
| 264 | return bsnGentableEntryDescStatsEntryVer13; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | public void putTo(PrimitiveSink sink) { |
| 269 | FUNNEL.funnel(this, sink); |
| 270 | } |
| 271 | |
| 272 | final static OFBsnGentableEntryDescStatsEntryVer13Funnel FUNNEL = new OFBsnGentableEntryDescStatsEntryVer13Funnel(); |
| 273 | static class OFBsnGentableEntryDescStatsEntryVer13Funnel implements Funnel<OFBsnGentableEntryDescStatsEntryVer13> { |
| 274 | private static final long serialVersionUID = 1L; |
| 275 | @Override |
| 276 | public void funnel(OFBsnGentableEntryDescStatsEntryVer13 message, PrimitiveSink sink) { |
| 277 | // FIXME: skip funnel of length |
| 278 | // FIXME: skip funnel of keyLength |
| 279 | message.checksum.putTo(sink); |
| 280 | FunnelUtils.putList(message.key, sink); |
| 281 | FunnelUtils.putList(message.value, sink); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | |
| 286 | public void writeTo(ChannelBuffer bb) { |
| 287 | WRITER.write(bb, this); |
| 288 | } |
| 289 | |
| 290 | final static Writer WRITER = new Writer(); |
| 291 | static class Writer implements OFMessageWriter<OFBsnGentableEntryDescStatsEntryVer13> { |
| 292 | @Override |
| 293 | public void write(ChannelBuffer bb, OFBsnGentableEntryDescStatsEntryVer13 message) { |
| 294 | int startIndex = bb.writerIndex(); |
| 295 | // length is length of variable message, will be updated at the end |
| 296 | int lengthIndex = bb.writerIndex(); |
| 297 | bb.writeShort(U16.t(0)); |
| 298 | |
| 299 | // keyLength is length indicator for key, will be |
| 300 | // udpated when key has been written |
| 301 | int keyLengthIndex = bb.writerIndex(); |
| 302 | bb.writeShort(0); |
| 303 | message.checksum.write16Bytes(bb); |
| 304 | int keyStartIndex = bb.writerIndex(); |
| 305 | ChannelUtils.writeList(bb, message.key); |
| 306 | // update field length member keyLength |
| 307 | int keyLength = bb.writerIndex() - keyStartIndex; |
| 308 | bb.setShort(keyLengthIndex, keyLength); |
| 309 | ChannelUtils.writeList(bb, message.value); |
| 310 | |
| 311 | // update length field |
| 312 | int length = bb.writerIndex() - startIndex; |
| 313 | bb.setShort(lengthIndex, length); |
| 314 | |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | @Override |
| 319 | public String toString() { |
| 320 | StringBuilder b = new StringBuilder("OFBsnGentableEntryDescStatsEntryVer13("); |
| 321 | b.append("checksum=").append(checksum); |
| 322 | b.append(", "); |
| 323 | b.append("key=").append(key); |
| 324 | b.append(", "); |
| 325 | b.append("value=").append(value); |
| 326 | b.append(")"); |
| 327 | return b.toString(); |
| 328 | } |
| 329 | |
| 330 | @Override |
| 331 | public boolean equals(Object obj) { |
| 332 | if (this == obj) |
| 333 | return true; |
| 334 | if (obj == null) |
| 335 | return false; |
| 336 | if (getClass() != obj.getClass()) |
| 337 | return false; |
| 338 | OFBsnGentableEntryDescStatsEntryVer13 other = (OFBsnGentableEntryDescStatsEntryVer13) obj; |
| 339 | |
| 340 | if (checksum == null) { |
| 341 | if (other.checksum != null) |
| 342 | return false; |
| 343 | } else if (!checksum.equals(other.checksum)) |
| 344 | return false; |
| 345 | if (key == null) { |
| 346 | if (other.key != null) |
| 347 | return false; |
| 348 | } else if (!key.equals(other.key)) |
| 349 | return false; |
| 350 | if (value == null) { |
| 351 | if (other.value != null) |
| 352 | return false; |
| 353 | } else if (!value.equals(other.value)) |
| 354 | return false; |
| 355 | return true; |
| 356 | } |
| 357 | |
| 358 | @Override |
| 359 | public int hashCode() { |
| 360 | final int prime = 31; |
| 361 | int result = 1; |
| 362 | |
| 363 | result = prime * result + ((checksum == null) ? 0 : checksum.hashCode()); |
| 364 | result = prime * result + ((key == null) ? 0 : key.hashCode()); |
| 365 | result = prime * result + ((value == null) ? 0 : value.hashCode()); |
| 366 | return result; |
| 367 | } |
| 368 | |
| 369 | } |