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 java.util.Set; |
| 27 | import org.slf4j.Logger; |
| 28 | import org.slf4j.LoggerFactory; |
| 29 | import java.util.List; |
| 30 | import com.google.common.collect.ImmutableList; |
| 31 | import org.jboss.netty.buffer.ChannelBuffer; |
| 32 | import com.google.common.hash.PrimitiveSink; |
| 33 | import com.google.common.hash.Funnel; |
| 34 | |
| 35 | class OFTableFeaturePropWriteSetfieldMissVer13 implements OFTableFeaturePropWriteSetfieldMiss { |
| 36 | private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropWriteSetfieldMissVer13.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<U32> DEFAULT_OXM_IDS = ImmutableList.<U32>of(); |
| 42 | |
| 43 | // OF message fields |
| 44 | private final List<U32> oxmIds; |
| 45 | // |
| 46 | // Immutable default instance |
| 47 | final static OFTableFeaturePropWriteSetfieldMissVer13 DEFAULT = new OFTableFeaturePropWriteSetfieldMissVer13( |
| 48 | DEFAULT_OXM_IDS |
| 49 | ); |
| 50 | |
| 51 | // package private constructor - used by readers, builders, and factory |
| 52 | OFTableFeaturePropWriteSetfieldMissVer13(List<U32> oxmIds) { |
| 53 | this.oxmIds = oxmIds; |
| 54 | } |
| 55 | |
| 56 | // Accessors for OF message fields |
| 57 | @Override |
| 58 | public int getType() { |
| 59 | return 0xd; |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public List<U32> getOxmIds() { |
| 64 | return oxmIds; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public OFVersion getVersion() { |
| 69 | return OFVersion.OF_13; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | |
| 74 | public OFTableFeaturePropWriteSetfieldMiss.Builder createBuilder() { |
| 75 | return new BuilderWithParent(this); |
| 76 | } |
| 77 | |
| 78 | static class BuilderWithParent implements OFTableFeaturePropWriteSetfieldMiss.Builder { |
| 79 | final OFTableFeaturePropWriteSetfieldMissVer13 parentMessage; |
| 80 | |
| 81 | // OF message fields |
| 82 | private boolean oxmIdsSet; |
| 83 | private List<U32> oxmIds; |
| 84 | |
| 85 | BuilderWithParent(OFTableFeaturePropWriteSetfieldMissVer13 parentMessage) { |
| 86 | this.parentMessage = parentMessage; |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public int getType() { |
| 91 | return 0xd; |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public List<U32> getOxmIds() { |
| 96 | return oxmIds; |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public OFTableFeaturePropWriteSetfieldMiss.Builder setOxmIds(List<U32> oxmIds) { |
| 101 | this.oxmIds = oxmIds; |
| 102 | this.oxmIdsSet = true; |
| 103 | return this; |
| 104 | } |
| 105 | @Override |
| 106 | public OFVersion getVersion() { |
| 107 | return OFVersion.OF_13; |
| 108 | } |
| 109 | |
| 110 | |
| 111 | |
| 112 | @Override |
| 113 | public OFTableFeaturePropWriteSetfieldMiss build() { |
| 114 | List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : parentMessage.oxmIds; |
| 115 | if(oxmIds == null) |
| 116 | throw new NullPointerException("Property oxmIds must not be null"); |
| 117 | |
| 118 | // |
| 119 | return new OFTableFeaturePropWriteSetfieldMissVer13( |
| 120 | oxmIds |
| 121 | ); |
| 122 | } |
| 123 | |
| 124 | } |
| 125 | |
| 126 | static class Builder implements OFTableFeaturePropWriteSetfieldMiss.Builder { |
| 127 | // OF message fields |
| 128 | private boolean oxmIdsSet; |
| 129 | private List<U32> oxmIds; |
| 130 | |
| 131 | @Override |
| 132 | public int getType() { |
| 133 | return 0xd; |
| 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public List<U32> getOxmIds() { |
| 138 | return oxmIds; |
| 139 | } |
| 140 | |
| 141 | @Override |
| 142 | public OFTableFeaturePropWriteSetfieldMiss.Builder setOxmIds(List<U32> oxmIds) { |
| 143 | this.oxmIds = oxmIds; |
| 144 | this.oxmIdsSet = true; |
| 145 | return this; |
| 146 | } |
| 147 | @Override |
| 148 | public OFVersion getVersion() { |
| 149 | return OFVersion.OF_13; |
| 150 | } |
| 151 | |
| 152 | // |
| 153 | @Override |
| 154 | public OFTableFeaturePropWriteSetfieldMiss build() { |
| 155 | List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : DEFAULT_OXM_IDS; |
| 156 | if(oxmIds == null) |
| 157 | throw new NullPointerException("Property oxmIds must not be null"); |
| 158 | |
| 159 | |
| 160 | return new OFTableFeaturePropWriteSetfieldMissVer13( |
| 161 | oxmIds |
| 162 | ); |
| 163 | } |
| 164 | |
| 165 | } |
| 166 | |
| 167 | |
| 168 | final static Reader READER = new Reader(); |
| 169 | static class Reader implements OFMessageReader<OFTableFeaturePropWriteSetfieldMiss> { |
| 170 | @Override |
| 171 | public OFTableFeaturePropWriteSetfieldMiss readFrom(ChannelBuffer bb) throws OFParseError { |
| 172 | int start = bb.readerIndex(); |
| 173 | // fixed value property type == 0xd |
| 174 | short type = bb.readShort(); |
| 175 | if(type != (short) 0xd) |
| 176 | throw new OFParseError("Wrong type: Expected=0xd(0xd), got="+type); |
| 177 | int length = U16.f(bb.readShort()); |
| 178 | if(length < MINIMUM_LENGTH) |
| 179 | throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); |
| 180 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 181 | // Buffer does not have all data yet |
| 182 | bb.readerIndex(start); |
| 183 | return null; |
| 184 | } |
| 185 | if(logger.isTraceEnabled()) |
| 186 | logger.trace("readFrom - length={}", length); |
| 187 | List<U32> oxmIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U32.READER); |
| 188 | |
| 189 | OFTableFeaturePropWriteSetfieldMissVer13 tableFeaturePropWriteSetfieldMissVer13 = new OFTableFeaturePropWriteSetfieldMissVer13( |
| 190 | oxmIds |
| 191 | ); |
| 192 | if(logger.isTraceEnabled()) |
| 193 | logger.trace("readFrom - read={}", tableFeaturePropWriteSetfieldMissVer13); |
| 194 | return tableFeaturePropWriteSetfieldMissVer13; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | public void putTo(PrimitiveSink sink) { |
| 199 | FUNNEL.funnel(this, sink); |
| 200 | } |
| 201 | |
| 202 | final static OFTableFeaturePropWriteSetfieldMissVer13Funnel FUNNEL = new OFTableFeaturePropWriteSetfieldMissVer13Funnel(); |
| 203 | static class OFTableFeaturePropWriteSetfieldMissVer13Funnel implements Funnel<OFTableFeaturePropWriteSetfieldMissVer13> { |
| 204 | private static final long serialVersionUID = 1L; |
| 205 | @Override |
| 206 | public void funnel(OFTableFeaturePropWriteSetfieldMissVer13 message, PrimitiveSink sink) { |
| 207 | // fixed value property type = 0xd |
| 208 | sink.putShort((short) 0xd); |
| 209 | // FIXME: skip funnel of length |
| 210 | FunnelUtils.putList(message.oxmIds, sink); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | |
| 215 | public void writeTo(ChannelBuffer bb) { |
| 216 | WRITER.write(bb, this); |
| 217 | } |
| 218 | |
| 219 | final static Writer WRITER = new Writer(); |
| 220 | static class Writer implements OFMessageWriter<OFTableFeaturePropWriteSetfieldMissVer13> { |
| 221 | @Override |
| 222 | public void write(ChannelBuffer bb, OFTableFeaturePropWriteSetfieldMissVer13 message) { |
| 223 | int startIndex = bb.writerIndex(); |
| 224 | // fixed value property type = 0xd |
| 225 | bb.writeShort((short) 0xd); |
| 226 | // length is length of variable message, will be updated at the end |
| 227 | int lengthIndex = bb.writerIndex(); |
| 228 | bb.writeShort(U16.t(0)); |
| 229 | |
| 230 | ChannelUtils.writeList(bb, message.oxmIds); |
| 231 | |
| 232 | // update length field |
| 233 | int length = bb.writerIndex() - startIndex; |
| 234 | bb.setShort(lengthIndex, length); |
| 235 | |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | @Override |
| 240 | public String toString() { |
| 241 | StringBuilder b = new StringBuilder("OFTableFeaturePropWriteSetfieldMissVer13("); |
| 242 | b.append("oxmIds=").append(oxmIds); |
| 243 | b.append(")"); |
| 244 | return b.toString(); |
| 245 | } |
| 246 | |
| 247 | @Override |
| 248 | public boolean equals(Object obj) { |
| 249 | if (this == obj) |
| 250 | return true; |
| 251 | if (obj == null) |
| 252 | return false; |
| 253 | if (getClass() != obj.getClass()) |
| 254 | return false; |
| 255 | OFTableFeaturePropWriteSetfieldMissVer13 other = (OFTableFeaturePropWriteSetfieldMissVer13) obj; |
| 256 | |
| 257 | if (oxmIds == null) { |
| 258 | if (other.oxmIds != null) |
| 259 | return false; |
| 260 | } else if (!oxmIds.equals(other.oxmIds)) |
| 261 | return false; |
| 262 | return true; |
| 263 | } |
| 264 | |
| 265 | @Override |
| 266 | public int hashCode() { |
| 267 | final int prime = 31; |
| 268 | int result = 1; |
| 269 | |
| 270 | result = prime * result + ((oxmIds == null) ? 0 : oxmIds.hashCode()); |
| 271 | return result; |
| 272 | } |
| 273 | |
| 274 | } |