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.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 OFBsnControllerConnectionVer13 implements OFBsnControllerConnection { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFBsnControllerConnectionVer13.class); |
| 35 | // version: 1.3 |
| 36 | final static byte WIRE_VERSION = 4; |
| 37 | final static int LENGTH = 264; |
| 38 | |
| 39 | private final static OFAuxId DEFAULT_AUXILIARY_ID = OFAuxId.MAIN; |
| 40 | private final static String DEFAULT_URI = ""; |
| 41 | |
| 42 | // OF message fields |
| 43 | private final OFBsnControllerConnectionState state; |
| 44 | private final OFAuxId auxiliaryId; |
| 45 | private final OFControllerRole role; |
| 46 | private final String uri; |
| 47 | // |
| 48 | |
| 49 | // package private constructor - used by readers, builders, and factory |
| 50 | OFBsnControllerConnectionVer13(OFBsnControllerConnectionState state, OFAuxId auxiliaryId, OFControllerRole role, String uri) { |
| 51 | this.state = state; |
| 52 | this.auxiliaryId = auxiliaryId; |
| 53 | this.role = role; |
| 54 | this.uri = uri; |
| 55 | } |
| 56 | |
| 57 | // Accessors for OF message fields |
| 58 | @Override |
| 59 | public OFBsnControllerConnectionState getState() { |
| 60 | return state; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public OFAuxId getAuxiliaryId() { |
| 65 | return auxiliaryId; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public OFControllerRole getRole() { |
| 70 | return role; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public String getUri() { |
| 75 | return uri; |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public OFVersion getVersion() { |
| 80 | return OFVersion.OF_13; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | |
| 85 | public OFBsnControllerConnection.Builder createBuilder() { |
| 86 | return new BuilderWithParent(this); |
| 87 | } |
| 88 | |
| 89 | static class BuilderWithParent implements OFBsnControllerConnection.Builder { |
| 90 | final OFBsnControllerConnectionVer13 parentMessage; |
| 91 | |
| 92 | // OF message fields |
| 93 | private boolean stateSet; |
| 94 | private OFBsnControllerConnectionState state; |
| 95 | private boolean auxiliaryIdSet; |
| 96 | private OFAuxId auxiliaryId; |
| 97 | private boolean roleSet; |
| 98 | private OFControllerRole role; |
| 99 | private boolean uriSet; |
| 100 | private String uri; |
| 101 | |
| 102 | BuilderWithParent(OFBsnControllerConnectionVer13 parentMessage) { |
| 103 | this.parentMessage = parentMessage; |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public OFBsnControllerConnectionState getState() { |
| 108 | return state; |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public OFBsnControllerConnection.Builder setState(OFBsnControllerConnectionState state) { |
| 113 | this.state = state; |
| 114 | this.stateSet = true; |
| 115 | return this; |
| 116 | } |
| 117 | @Override |
| 118 | public OFAuxId getAuxiliaryId() { |
| 119 | return auxiliaryId; |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public OFBsnControllerConnection.Builder setAuxiliaryId(OFAuxId auxiliaryId) { |
| 124 | this.auxiliaryId = auxiliaryId; |
| 125 | this.auxiliaryIdSet = true; |
| 126 | return this; |
| 127 | } |
| 128 | @Override |
| 129 | public OFControllerRole getRole() { |
| 130 | return role; |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public OFBsnControllerConnection.Builder setRole(OFControllerRole role) { |
| 135 | this.role = role; |
| 136 | this.roleSet = true; |
| 137 | return this; |
| 138 | } |
| 139 | @Override |
| 140 | public String getUri() { |
| 141 | return uri; |
| 142 | } |
| 143 | |
| 144 | @Override |
| 145 | public OFBsnControllerConnection.Builder setUri(String uri) { |
| 146 | this.uri = uri; |
| 147 | this.uriSet = true; |
| 148 | return this; |
| 149 | } |
| 150 | @Override |
| 151 | public OFVersion getVersion() { |
| 152 | return OFVersion.OF_13; |
| 153 | } |
| 154 | |
| 155 | |
| 156 | |
| 157 | @Override |
| 158 | public OFBsnControllerConnection build() { |
| 159 | OFBsnControllerConnectionState state = this.stateSet ? this.state : parentMessage.state; |
| 160 | if(state == null) |
| 161 | throw new NullPointerException("Property state must not be null"); |
| 162 | OFAuxId auxiliaryId = this.auxiliaryIdSet ? this.auxiliaryId : parentMessage.auxiliaryId; |
| 163 | if(auxiliaryId == null) |
| 164 | throw new NullPointerException("Property auxiliaryId must not be null"); |
| 165 | OFControllerRole role = this.roleSet ? this.role : parentMessage.role; |
| 166 | if(role == null) |
| 167 | throw new NullPointerException("Property role must not be null"); |
| 168 | String uri = this.uriSet ? this.uri : parentMessage.uri; |
| 169 | if(uri == null) |
| 170 | throw new NullPointerException("Property uri must not be null"); |
| 171 | |
| 172 | // |
| 173 | return new OFBsnControllerConnectionVer13( |
| 174 | state, |
| 175 | auxiliaryId, |
| 176 | role, |
| 177 | uri |
| 178 | ); |
| 179 | } |
| 180 | |
| 181 | } |
| 182 | |
| 183 | static class Builder implements OFBsnControllerConnection.Builder { |
| 184 | // OF message fields |
| 185 | private boolean stateSet; |
| 186 | private OFBsnControllerConnectionState state; |
| 187 | private boolean auxiliaryIdSet; |
| 188 | private OFAuxId auxiliaryId; |
| 189 | private boolean roleSet; |
| 190 | private OFControllerRole role; |
| 191 | private boolean uriSet; |
| 192 | private String uri; |
| 193 | |
| 194 | @Override |
| 195 | public OFBsnControllerConnectionState getState() { |
| 196 | return state; |
| 197 | } |
| 198 | |
| 199 | @Override |
| 200 | public OFBsnControllerConnection.Builder setState(OFBsnControllerConnectionState state) { |
| 201 | this.state = state; |
| 202 | this.stateSet = true; |
| 203 | return this; |
| 204 | } |
| 205 | @Override |
| 206 | public OFAuxId getAuxiliaryId() { |
| 207 | return auxiliaryId; |
| 208 | } |
| 209 | |
| 210 | @Override |
| 211 | public OFBsnControllerConnection.Builder setAuxiliaryId(OFAuxId auxiliaryId) { |
| 212 | this.auxiliaryId = auxiliaryId; |
| 213 | this.auxiliaryIdSet = true; |
| 214 | return this; |
| 215 | } |
| 216 | @Override |
| 217 | public OFControllerRole getRole() { |
| 218 | return role; |
| 219 | } |
| 220 | |
| 221 | @Override |
| 222 | public OFBsnControllerConnection.Builder setRole(OFControllerRole role) { |
| 223 | this.role = role; |
| 224 | this.roleSet = true; |
| 225 | return this; |
| 226 | } |
| 227 | @Override |
| 228 | public String getUri() { |
| 229 | return uri; |
| 230 | } |
| 231 | |
| 232 | @Override |
| 233 | public OFBsnControllerConnection.Builder setUri(String uri) { |
| 234 | this.uri = uri; |
| 235 | this.uriSet = true; |
| 236 | return this; |
| 237 | } |
| 238 | @Override |
| 239 | public OFVersion getVersion() { |
| 240 | return OFVersion.OF_13; |
| 241 | } |
| 242 | |
| 243 | // |
| 244 | @Override |
| 245 | public OFBsnControllerConnection build() { |
| 246 | if(!this.stateSet) |
| 247 | throw new IllegalStateException("Property state doesn't have default value -- must be set"); |
| 248 | if(state == null) |
| 249 | throw new NullPointerException("Property state must not be null"); |
| 250 | OFAuxId auxiliaryId = this.auxiliaryIdSet ? this.auxiliaryId : DEFAULT_AUXILIARY_ID; |
| 251 | if(auxiliaryId == null) |
| 252 | throw new NullPointerException("Property auxiliaryId must not be null"); |
| 253 | if(!this.roleSet) |
| 254 | throw new IllegalStateException("Property role doesn't have default value -- must be set"); |
| 255 | if(role == null) |
| 256 | throw new NullPointerException("Property role must not be null"); |
| 257 | String uri = this.uriSet ? this.uri : DEFAULT_URI; |
| 258 | if(uri == null) |
| 259 | throw new NullPointerException("Property uri must not be null"); |
| 260 | |
| 261 | |
| 262 | return new OFBsnControllerConnectionVer13( |
| 263 | state, |
| 264 | auxiliaryId, |
| 265 | role, |
| 266 | uri |
| 267 | ); |
| 268 | } |
| 269 | |
| 270 | } |
| 271 | |
| 272 | |
| 273 | final static Reader READER = new Reader(); |
| 274 | static class Reader implements OFMessageReader<OFBsnControllerConnection> { |
| 275 | @Override |
| 276 | public OFBsnControllerConnection readFrom(ChannelBuffer bb) throws OFParseError { |
| 277 | OFBsnControllerConnectionState state = OFBsnControllerConnectionStateSerializerVer13.readFrom(bb); |
| 278 | OFAuxId auxiliaryId = OFAuxId.readByte(bb); |
| 279 | // pad: 2 bytes |
| 280 | bb.skipBytes(2); |
| 281 | OFControllerRole role = OFControllerRoleSerializerVer13.readFrom(bb); |
| 282 | String uri = ChannelUtils.readFixedLengthString(bb, 256); |
| 283 | |
| 284 | OFBsnControllerConnectionVer13 bsnControllerConnectionVer13 = new OFBsnControllerConnectionVer13( |
| 285 | state, |
| 286 | auxiliaryId, |
| 287 | role, |
| 288 | uri |
| 289 | ); |
| 290 | if(logger.isTraceEnabled()) |
| 291 | logger.trace("readFrom - read={}", bsnControllerConnectionVer13); |
| 292 | return bsnControllerConnectionVer13; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | public void putTo(PrimitiveSink sink) { |
| 297 | FUNNEL.funnel(this, sink); |
| 298 | } |
| 299 | |
| 300 | final static OFBsnControllerConnectionVer13Funnel FUNNEL = new OFBsnControllerConnectionVer13Funnel(); |
| 301 | static class OFBsnControllerConnectionVer13Funnel implements Funnel<OFBsnControllerConnectionVer13> { |
| 302 | private static final long serialVersionUID = 1L; |
| 303 | @Override |
| 304 | public void funnel(OFBsnControllerConnectionVer13 message, PrimitiveSink sink) { |
| 305 | OFBsnControllerConnectionStateSerializerVer13.putTo(message.state, sink); |
| 306 | message.auxiliaryId.putTo(sink); |
| 307 | // skip pad (2 bytes) |
| 308 | OFControllerRoleSerializerVer13.putTo(message.role, sink); |
| 309 | sink.putUnencodedChars(message.uri); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 314 | public void writeTo(ChannelBuffer bb) { |
| 315 | WRITER.write(bb, this); |
| 316 | } |
| 317 | |
| 318 | final static Writer WRITER = new Writer(); |
| 319 | static class Writer implements OFMessageWriter<OFBsnControllerConnectionVer13> { |
| 320 | @Override |
| 321 | public void write(ChannelBuffer bb, OFBsnControllerConnectionVer13 message) { |
| 322 | OFBsnControllerConnectionStateSerializerVer13.writeTo(bb, message.state); |
| 323 | message.auxiliaryId.writeByte(bb); |
| 324 | // pad: 2 bytes |
| 325 | bb.writeZero(2); |
| 326 | OFControllerRoleSerializerVer13.writeTo(bb, message.role); |
| 327 | ChannelUtils.writeFixedLengthString(bb, message.uri, 256); |
| 328 | |
| 329 | |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | @Override |
| 334 | public String toString() { |
| 335 | StringBuilder b = new StringBuilder("OFBsnControllerConnectionVer13("); |
| 336 | b.append("state=").append(state); |
| 337 | b.append(", "); |
| 338 | b.append("auxiliaryId=").append(auxiliaryId); |
| 339 | b.append(", "); |
| 340 | b.append("role=").append(role); |
| 341 | b.append(", "); |
| 342 | b.append("uri=").append(uri); |
| 343 | b.append(")"); |
| 344 | return b.toString(); |
| 345 | } |
| 346 | |
| 347 | @Override |
| 348 | public boolean equals(Object obj) { |
| 349 | if (this == obj) |
| 350 | return true; |
| 351 | if (obj == null) |
| 352 | return false; |
| 353 | if (getClass() != obj.getClass()) |
| 354 | return false; |
| 355 | OFBsnControllerConnectionVer13 other = (OFBsnControllerConnectionVer13) obj; |
| 356 | |
| 357 | if (state == null) { |
| 358 | if (other.state != null) |
| 359 | return false; |
| 360 | } else if (!state.equals(other.state)) |
| 361 | return false; |
| 362 | if (auxiliaryId == null) { |
| 363 | if (other.auxiliaryId != null) |
| 364 | return false; |
| 365 | } else if (!auxiliaryId.equals(other.auxiliaryId)) |
| 366 | return false; |
| 367 | if (role == null) { |
| 368 | if (other.role != null) |
| 369 | return false; |
| 370 | } else if (!role.equals(other.role)) |
| 371 | return false; |
| 372 | if (uri == null) { |
| 373 | if (other.uri != null) |
| 374 | return false; |
| 375 | } else if (!uri.equals(other.uri)) |
| 376 | return false; |
| 377 | return true; |
| 378 | } |
| 379 | |
| 380 | @Override |
| 381 | public int hashCode() { |
| 382 | final int prime = 31; |
| 383 | int result = 1; |
| 384 | |
| 385 | result = prime * result + ((state == null) ? 0 : state.hashCode()); |
| 386 | result = prime * result + ((auxiliaryId == null) ? 0 : auxiliaryId.hashCode()); |
| 387 | result = prime * result + ((role == null) ? 0 : role.hashCode()); |
| 388 | result = prime * result + ((uri == null) ? 0 : uri.hashCode()); |
| 389 | return result; |
| 390 | } |
| 391 | |
| 392 | } |