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