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