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