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