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