blob: f0e6c2a8e5291ae86814122a959faf6cc0dff9db [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001// 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
10package org.projectfloodlight.openflow.protocol.ver11;
11
12import org.projectfloodlight.openflow.protocol.*;
13import org.projectfloodlight.openflow.protocol.action.*;
14import org.projectfloodlight.openflow.protocol.actionid.*;
15import org.projectfloodlight.openflow.protocol.bsntlv.*;
16import org.projectfloodlight.openflow.protocol.errormsg.*;
17import org.projectfloodlight.openflow.protocol.meterband.*;
18import org.projectfloodlight.openflow.protocol.instruction.*;
19import org.projectfloodlight.openflow.protocol.instructionid.*;
20import org.projectfloodlight.openflow.protocol.match.*;
21import org.projectfloodlight.openflow.protocol.oxm.*;
22import org.projectfloodlight.openflow.protocol.queueprop.*;
23import org.projectfloodlight.openflow.types.*;
24import org.projectfloodlight.openflow.util.*;
25import org.projectfloodlight.openflow.exceptions.*;
26import org.slf4j.Logger;
27import org.slf4j.LoggerFactory;
28import java.util.Set;
29import org.jboss.netty.buffer.ChannelBuffer;
30import com.google.common.hash.PrimitiveSink;
31import com.google.common.hash.Funnel;
32
33class OFActionGroupVer11 implements OFActionGroup {
34 private static final Logger logger = LoggerFactory.getLogger(OFActionGroupVer11.class);
35 // version: 1.1
36 final static byte WIRE_VERSION = 2;
37 final static int LENGTH = 8;
38
39 private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
40
41 // OF message fields
42 private final OFGroup group;
43//
44 // Immutable default instance
45 final static OFActionGroupVer11 DEFAULT = new OFActionGroupVer11(
46 DEFAULT_GROUP_ID
47 );
48
49 // package private constructor - used by readers, builders, and factory
50 OFActionGroupVer11(OFGroup group) {
51 this.group = group;
52 }
53
54 // Accessors for OF message fields
55 @Override
56 public OFActionType getType() {
57 return OFActionType.GROUP;
58 }
59
60 @Override
61 public OFGroup getGroup() {
62 return group;
63 }
64
65 @Override
66 public OFVersion getVersion() {
67 return OFVersion.OF_11;
68 }
69
70
71
72 public OFActionGroup.Builder createBuilder() {
73 return new BuilderWithParent(this);
74 }
75
76 static class BuilderWithParent implements OFActionGroup.Builder {
77 final OFActionGroupVer11 parentMessage;
78
79 // OF message fields
80 private boolean groupSet;
81 private OFGroup group;
82
83 BuilderWithParent(OFActionGroupVer11 parentMessage) {
84 this.parentMessage = parentMessage;
85 }
86
87 @Override
88 public OFActionType getType() {
89 return OFActionType.GROUP;
90 }
91
92 @Override
93 public OFGroup getGroup() {
94 return group;
95 }
96
97 @Override
98 public OFActionGroup.Builder setGroup(OFGroup group) {
99 this.group = group;
100 this.groupSet = true;
101 return this;
102 }
103 @Override
104 public OFVersion getVersion() {
105 return OFVersion.OF_11;
106 }
107
108
109
110 @Override
111 public OFActionGroup build() {
112 OFGroup group = this.groupSet ? this.group : parentMessage.group;
113 if(group == null)
114 throw new NullPointerException("Property group must not be null");
115
116 //
117 return new OFActionGroupVer11(
118 group
119 );
120 }
121
122 }
123
124 static class Builder implements OFActionGroup.Builder {
125 // OF message fields
126 private boolean groupSet;
127 private OFGroup group;
128
129 @Override
130 public OFActionType getType() {
131 return OFActionType.GROUP;
132 }
133
134 @Override
135 public OFGroup getGroup() {
136 return group;
137 }
138
139 @Override
140 public OFActionGroup.Builder setGroup(OFGroup group) {
141 this.group = group;
142 this.groupSet = true;
143 return this;
144 }
145 @Override
146 public OFVersion getVersion() {
147 return OFVersion.OF_11;
148 }
149
150//
151 @Override
152 public OFActionGroup build() {
153 OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
154 if(group == null)
155 throw new NullPointerException("Property group must not be null");
156
157
158 return new OFActionGroupVer11(
159 group
160 );
161 }
162
163 }
164
165
166 final static Reader READER = new Reader();
167 static class Reader implements OFMessageReader<OFActionGroup> {
168 @Override
169 public OFActionGroup readFrom(ChannelBuffer bb) throws OFParseError {
170 int start = bb.readerIndex();
171 // fixed value property type == 22
172 short type = bb.readShort();
173 if(type != (short) 0x16)
174 throw new OFParseError("Wrong type: Expected=OFActionType.GROUP(22), got="+type);
175 int length = U16.f(bb.readShort());
176 if(length != 8)
177 throw new OFParseError("Wrong length: Expected=8(8), 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 OFGroup group = OFGroup.read4Bytes(bb);
186
187 OFActionGroupVer11 actionGroupVer11 = new OFActionGroupVer11(
188 group
189 );
190 if(logger.isTraceEnabled())
191 logger.trace("readFrom - read={}", actionGroupVer11);
192 return actionGroupVer11;
193 }
194 }
195
196 public void putTo(PrimitiveSink sink) {
197 FUNNEL.funnel(this, sink);
198 }
199
200 final static OFActionGroupVer11Funnel FUNNEL = new OFActionGroupVer11Funnel();
201 static class OFActionGroupVer11Funnel implements Funnel<OFActionGroupVer11> {
202 private static final long serialVersionUID = 1L;
203 @Override
204 public void funnel(OFActionGroupVer11 message, PrimitiveSink sink) {
205 // fixed value property type = 22
206 sink.putShort((short) 0x16);
207 // fixed value property length = 8
208 sink.putShort((short) 0x8);
209 message.group.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<OFActionGroupVer11> {
220 @Override
221 public void write(ChannelBuffer bb, OFActionGroupVer11 message) {
222 // fixed value property type = 22
223 bb.writeShort((short) 0x16);
224 // fixed value property length = 8
225 bb.writeShort((short) 0x8);
226 message.group.write4Bytes(bb);
227
228
229 }
230 }
231
232 @Override
233 public String toString() {
234 StringBuilder b = new StringBuilder("OFActionGroupVer11(");
235 b.append("group=").append(group);
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 OFActionGroupVer11 other = (OFActionGroupVer11) obj;
249
250 if (group == null) {
251 if (other.group != null)
252 return false;
253 } else if (!group.equals(other.group))
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 + ((group == null) ? 0 : group.hashCode());
264 return result;
265 }
266
267}