blob: 7b3b762d33ffec1214fc0631695fe82cb72a0a6a [file] [log] [blame]
Andreas Wundsam27303462013-07-16 12:52:35 -07001//:: # Copyright 2013, Big Switch Networks, Inc.
2//:: #
3//:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
4//:: # the following special exception:
5//:: #
6//:: # LOXI Exception
7//:: #
8//:: # As a special exception to the terms of the EPL, you may distribute libraries
9//:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
10//:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
11//:: # from the LoxiGen Libraries and the notice provided below is (i) included in
12//:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
13//:: # documentation for the LoxiGen Libraries, if distributed in binary form.
14//:: #
15//:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
16//:: #
17//:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
18//:: # a copy of the EPL at:
19//:: #
20//:: # http::: #www.eclipse.org/legal/epl-v10.html
21//:: #
22//:: # Unless required by applicable law or agreed to in writing, software
23//:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24//:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
25//:: # EPL for the specific language governing permissions and limitations
26//:: # under the EPL.
27//::
28//:: from loxi_ir import *
Andreas Wundsambc679f72013-08-01 22:13:09 -070029//:: import os
Andreas Wundsam27303462013-07-16 12:52:35 -070030//:: import itertools
31//:: import of_g
32//:: include('_copyright.java')
33
34//:: include('_autogen.java')
35
36package ${msg.package};
37
38//:: include("_imports.java", msg=msg)
39
Andreas Wundsam99e931d2013-08-22 07:53:53 -070040class ${impl_class} implements ${msg.interface.inherited_declaration()} {
Andreas Wundsam27303462013-07-16 12:52:35 -070041 // version: ${version}
Yotam Harchol791e4882013-09-05 16:32:56 -070042 final static byte WIRE_VERSION = ${version.int_version};
Andreas Wundsam27303462013-07-16 12:52:35 -070043//:: if msg.is_fixed_length:
Yotam Harchol791e4882013-09-05 16:32:56 -070044 final static int LENGTH = ${msg.length};
Andreas Wundsam27303462013-07-16 12:52:35 -070045//:: else:
Yotam Harchol791e4882013-09-05 16:32:56 -070046 final static int MINIMUM_LENGTH = ${msg.min_length};
Andreas Wundsam27303462013-07-16 12:52:35 -070047//:: #endif
48
49//:: for prop in msg.data_members:
Andreas Wundsamf89f7822013-09-23 14:49:24 -070050 //:: if prop.default_value:
51 private final static ${prop.java_type.public_type} ${prop.default_name} = ${prop.default_value};
52 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070053//:: #end
54
55 // OF message fields
56//:: for prop in msg.data_members:
57 private final ${prop.java_type.public_type} ${prop.name};
58//:: #endfor
Andreas Wundsame962d372013-10-02 18:15:58 -070059//
60//:: if all(prop.default_value for prop in msg.data_members):
61 // Immutable default instance
62 final static ${impl_class} DEFAULT = new ${impl_class}(
63 ${", ".join(prop.default_name for prop in msg.data_members)}
64 );
65//:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070066
Andreas Wundsam99e931d2013-08-22 07:53:53 -070067 //:: if msg.data_members:
68 // package private constructor - used by readers, builders, and factory
Andreas Wundsam27303462013-07-16 12:52:35 -070069 ${impl_class}(${
70 ", ".join("%s %s" %(prop.java_type.public_type, prop.name) for prop in msg.data_members) }) {
71//:: for prop in msg.data_members:
72 this.${prop.name} = ${prop.name};
73//:: #endfor
74 }
Andreas Wundsam99e931d2013-08-22 07:53:53 -070075 //:: else:
76 final static ${impl_class} INSTANCE = new ${impl_class}();
77 // private empty constructor - use shared instance!
78 private ${impl_class}() {
79 }
80 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070081
82 // Accessors for OF message fields
Yotam Harcholf25e8142013-09-09 14:30:13 -070083 //:: include("_field_accessors.java", msg=msg, generate_setters=False, builder=False, has_parent=False)
Andreas Wundsam27303462013-07-16 12:52:35 -070084
Andreas Wundsambc679f72013-08-01 22:13:09 -070085 //:: if os.path.exists("%s/custom/%s.java" % (template_dir, msg.name)):
86 //:: include("custom/%s.java" % msg.name, msg=msg)
87 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070088
Andreas Wundsam99e931d2013-08-22 07:53:53 -070089 //:: if msg.data_members:
Andreas Wundsam5204de22013-07-30 11:34:45 -070090 public ${msg.interface.name}.Builder createBuilder() {
91 return new BuilderWithParent(this);
Andreas Wundsam27303462013-07-16 12:52:35 -070092 }
93
Andreas Wundsam5204de22013-07-30 11:34:45 -070094 static class BuilderWithParent implements ${msg.interface.name}.Builder {
Andreas Wundsam27303462013-07-16 12:52:35 -070095 final ${impl_class} parentMessage;
96
97 // OF message fields
98//:: for prop in msg.data_members:
99 private boolean ${prop.name}Set;
100 private ${prop.java_type.public_type} ${prop.name};
101//:: #endfor
102
Andreas Wundsam5204de22013-07-30 11:34:45 -0700103 BuilderWithParent(${impl_class} parentMessage) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700104 this.parentMessage = parentMessage;
105 }
106
Yotam Harcholf25e8142013-09-09 14:30:13 -0700107//:: include("_field_accessors.java", msg=msg, generate_setters=True, builder=True, has_parent=True)
Andreas Wundsam27303462013-07-16 12:52:35 -0700108
Andreas Wundsamf89f7822013-09-23 14:49:24 -0700109
Andreas Wundsam27303462013-07-16 12:52:35 -0700110 @Override
Andreas Wundsam99e931d2013-08-22 07:53:53 -0700111 public ${msg.interface.name} build() {
Andreas Wundsamf89f7822013-09-23 14:49:24 -0700112 //:: for prop in msg.data_members:
113 ${prop.java_type.public_type} ${prop.name} = this.${prop.name}Set ? this.${prop.name} : parentMessage.${prop.name};
114 //:: if not prop.is_nullable and not prop.java_type.is_primitive:
115 if(${prop.name} == null)
116 throw new NullPointerException("Property ${prop.name} must not be null");
117 //:: #endif
118 //:: #endfor
119
120 //
121 //:: if os.path.exists("%s/custom/%s.Builder_normalize_stanza.java" % (template_dir, msg.name)):
122 //:: include("custom/%s.Builder_normalize_stanza.java" % msg.name, msg=msg, has_parent=False)
123 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -0700124 return new ${impl_class}(
Andreas Wundsamf89f7822013-09-23 14:49:24 -0700125 //:: for i, prop in enumerate(msg.data_members):
126 //:: comma = "," if i < len(msg.data_members)-1 else ""
127 ${prop.name}${comma}
128 //:: #endfor
129 );
Andreas Wundsam27303462013-07-16 12:52:35 -0700130 }
Andreas Wundsambc679f72013-08-01 22:13:09 -0700131 //:: if os.path.exists("%s/custom/%s.Builder.java" % (template_dir, msg.name)):
Yotam Harchol98af7752013-08-22 14:59:38 -0700132 //:: include("custom/%s.Builder.java" % msg.name, msg=msg, has_parent=True)
Andreas Wundsambc679f72013-08-01 22:13:09 -0700133 //:: #endif
134
Andreas Wundsam27303462013-07-16 12:52:35 -0700135 }
136
Andreas Wundsam5204de22013-07-30 11:34:45 -0700137 static class Builder implements ${msg.interface.name}.Builder {
Andreas Wundsam27303462013-07-16 12:52:35 -0700138 // OF message fields
139//:: for prop in msg.data_members:
140 private boolean ${prop.name}Set;
141 private ${prop.java_type.public_type} ${prop.name};
142//:: #endfor
143
Yotam Harcholf25e8142013-09-09 14:30:13 -0700144//:: include("_field_accessors.java", msg=msg, generate_setters=True, builder=True, has_parent=False)
Andreas Wundsam27303462013-07-16 12:52:35 -0700145//
146 @Override
Andreas Wundsam99e931d2013-08-22 07:53:53 -0700147 public ${msg.interface.name} build() {
Andreas Wundsamf89f7822013-09-23 14:49:24 -0700148 //:: for prop in msg.data_members:
149 //:: if prop.default_value:
150 ${prop.java_type.public_type} ${prop.name} = this.${prop.name}Set ? this.${prop.name} : ${prop.default_name};
151 //:: else:
152 if(!this.${prop.name}Set)
153 throw new IllegalStateException("Property ${prop.name} doesn't have default value -- must be set");
154 //:: #endif
155 //:: if not prop.is_nullable and not prop.java_type.is_primitive:
156 if(${prop.name} == null)
157 throw new NullPointerException("Property ${prop.name} must not be null");
158 //:: #endif
159 //:: #endfor
160
161 //:: if os.path.exists("%s/custom/%s.Builder_normalize_stanza.java" % (template_dir, msg.name)):
162 //:: include("custom/%s.Builder_normalize_stanza.java" % msg.name, msg=msg, has_parent=False)
163 //:: #endif
164
Andreas Wundsam27303462013-07-16 12:52:35 -0700165 return new ${impl_class}(
Andreas Wundsamf89f7822013-09-23 14:49:24 -0700166 //:: for i, prop in enumerate(msg.data_members):
167 //:: comma = "," if i < len(msg.data_members)-1 else ""
168 ${prop.name}${comma}
169 //:: #endfor
Andreas Wundsam27303462013-07-16 12:52:35 -0700170 );
171 }
Andreas Wundsambc679f72013-08-01 22:13:09 -0700172 //:: if os.path.exists("%s/custom/%s.Builder.java" % (template_dir, msg.name)):
Yotam Harchol98af7752013-08-22 14:59:38 -0700173 //:: include("custom/%s.Builder.java" % msg.name, msg=msg, has_parent=False)
Andreas Wundsambc679f72013-08-01 22:13:09 -0700174 //:: #endif
175
Andreas Wundsam27303462013-07-16 12:52:35 -0700176 }
Andreas Wundsam99e931d2013-08-22 07:53:53 -0700177 //:: else:
178 // no data members - do not support builder
179 public ${msg.interface.name}.Builder createBuilder() {
180 throw new UnsupportedOperationException("${impl_class} has no mutable properties -- builder unneeded");
181 }
182 //:: #endif
183
Andreas Wundsam27303462013-07-16 12:52:35 -0700184
185 final static Reader READER = new Reader();
186 static class Reader implements OFMessageReader<${msg.interface.name}> {
187 @Override
188 public ${msg.interface.name} readFrom(ChannelBuffer bb) throws OFParseError {
Yotam Harchola86e4252013-09-06 15:36:28 -0700189//:: for prop in msg.members:
190//:: if not prop.is_virtual and (prop.is_length_value or prop.is_field_length_value):
Andreas Wundsam001b1822013-08-02 22:25:55 -0700191 int start = bb.readerIndex();
Yotam Harchola86e4252013-09-06 15:36:28 -0700192//:: break
193//:: #endif
194//:: #endfor
Andreas Wundsam27303462013-07-16 12:52:35 -0700195//:: fields_with_length_member = {}
196//:: for prop in msg.members:
Andreas Wundsam99e931d2013-08-22 07:53:53 -0700197//:: if prop.is_virtual:
198//:: continue
199//:: elif prop.is_data:
Andreas Wundsam001b1822013-08-02 22:25:55 -0700200 ${prop.java_type.public_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=True,
Andreas Wundsam27303462013-07-16 12:52:35 -0700201 length=fields_with_length_member[prop.c_name] if prop.c_name in fields_with_length_member else None)};
202//:: elif prop.is_pad:
203 // pad: ${prop.length} bytes
204 bb.skipBytes(${prop.length});
Andreas Wundsam27303462013-07-16 12:52:35 -0700205//:: elif prop.is_length_value:
Andreas Wundsam83d877a2013-09-30 14:26:44 -0700206 ${prop.java_type.public_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=True)};
207 //:: if prop.is_fixed_value:
208 if(${prop.name} != ${prop.value})
209 throw new OFParseError("Wrong ${prop.name}: Expected=${prop.enum_value}(${prop.value}), got="+${prop.name});
210 //:: else:
Andreas Wundsam27303462013-07-16 12:52:35 -0700211 if(${prop.name} < MINIMUM_LENGTH)
212 throw new OFParseError("Wrong ${prop.name}: Expected to be >= " + MINIMUM_LENGTH + ", was: " + ${prop.name});
Andreas Wundsam83d877a2013-09-30 14:26:44 -0700213 //:: #endif
Yotam Harchol0178c202013-09-05 16:25:50 -0700214 if(bb.readableBytes() + (bb.readerIndex() - start) < ${prop.name}) {
215 // Buffer does not have all data yet
216 bb.readerIndex(start);
217 return null;
218 }
Andreas Wundsam83d877a2013-09-30 14:26:44 -0700219//:: elif prop.is_fixed_value:
220 // fixed value property ${prop.name} == ${prop.value}
221 ${prop.java_type.priv_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=False)};
222 if(${prop.name} != ${prop.priv_value})
223 throw new OFParseError("Wrong ${prop.name}: Expected=${prop.enum_value}(${prop.value}), got="+${prop.name});
224//:: elif prop.is_field_length_value:
225//:: fields_with_length_member[prop.member.field_name] = prop.name
226 ${prop.java_type.public_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=True)};
227//:: else:
228 // fixme: todo ${prop.name}
Yotam Harchol0178c202013-09-05 16:25:50 -0700229//:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -0700230//:: #endfor
Andreas Wundsam758c9cc2013-08-01 22:16:06 -0700231 //:: if msg.align:
Andreas Wundsam87bdcf42013-10-23 15:19:01 -0700232 //:: if msg.length_includes_align:
233 // align message to ${msg.align} bytes (length contains aligned value)
234 bb.skipBytes(length - (bb.readerIndex() - start));
235 //:: else:
236 // align message to ${msg.align} bytes (length does not contain alignment)
Andreas Wundsam758c9cc2013-08-01 22:16:06 -0700237 bb.skipBytes(((length + ${msg.align-1})/${msg.align} * ${msg.align} ) - length );
238 //:: #endif
Andreas Wundsam87bdcf42013-10-23 15:19:01 -0700239 //:: #endif
Andreas Wundsam758c9cc2013-08-01 22:16:06 -0700240
Andreas Wundsam99e931d2013-08-22 07:53:53 -0700241 //:: if msg.data_members:
Andreas Wundsamf89f7822013-09-23 14:49:24 -0700242 //:: if os.path.exists("%s/custom/%s.Reader_normalize_stanza.java" % (template_dir, msg.name)):
243 //:: include("custom/%s.Reader_normalize_stanza.java" % msg.name, msg=msg, has_parent=False)
244 //:: #endif
245 return new ${impl_class}(
Andreas Wundsam27303462013-07-16 12:52:35 -0700246 ${",\n ".join(
247 [ prop.name for prop in msg.data_members])}
248 );
Andreas Wundsam99e931d2013-08-22 07:53:53 -0700249 //:: else:
250 return INSTANCE;
251 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -0700252 }
253 }
254
Andreas Wundsam22ba3af2013-10-04 16:00:30 -0700255 public void putTo(PrimitiveSink sink) {
256 FUNNEL.funnel(this, sink);
257 }
258
259 final static ${impl_class}Funnel FUNNEL = new ${impl_class}Funnel();
260 static class ${impl_class}Funnel implements Funnel<${impl_class}> {
261 private static final long serialVersionUID = 1L;
262 @Override
263 public void funnel(${impl_class} message, PrimitiveSink sink) {
264//:: for prop in msg.members:
265//:: if prop.is_virtual:
266//:: continue
267//:: elif prop.is_data:
268 ${prop.java_type.funnel_op(version, "message." + prop.name, pub_type=True)};
269//:: elif prop.is_pad:
270 // skip pad (${prop.length} bytes)
271//:: elif prop.is_fixed_value:
272 // fixed value property ${prop.name} = ${prop.value}
273 ${prop.java_type.funnel_op(version, prop.priv_value, pub_type=False)};
274//:: else:
275 // FIXME: skip funnel of ${prop.name}
276//:: #endif
277//:: #endfor
278 }
279 }
280
281
Yotam Harchol5c9d6f42013-08-01 11:09:20 -0700282 public void writeTo(ChannelBuffer bb) {
283 WRITER.write(bb, this);
Andreas Wundsam27303462013-07-16 12:52:35 -0700284 }
285
286 final static Writer WRITER = new Writer();
287 static class Writer implements OFMessageWriter<${impl_class}> {
288 @Override
Andreas Wundsama94273b2013-08-01 22:11:33 -0700289 public void write(ChannelBuffer bb, ${impl_class} message) {
Yotam Harchola86e4252013-09-06 15:36:28 -0700290//:: if not msg.is_fixed_length:
Andreas Wundsam482f6d92013-07-24 16:10:21 -0700291 int startIndex = bb.writerIndex();
Yotam Harchola86e4252013-09-06 15:36:28 -0700292//:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -0700293//:: fields_with_length_member = {}
294//:: for prop in msg.members:
295//:: if prop.c_name in fields_with_length_member:
296 int ${prop.name}StartIndex = bb.writerIndex();
297//:: #endif
Andreas Wundsam99e931d2013-08-22 07:53:53 -0700298//:: if prop.is_virtual:
299//:: continue
300//:: elif prop.is_data:
Andreas Wundsam001b1822013-08-02 22:25:55 -0700301 ${prop.java_type.write_op(version, "message." + prop.name, pub_type=True)};
Andreas Wundsam27303462013-07-16 12:52:35 -0700302//:: elif prop.is_pad:
303 // pad: ${prop.length} bytes
304 bb.writeZero(${prop.length});
305//:: elif prop.is_fixed_value:
306 // fixed value property ${prop.name} = ${prop.value}
Andreas Wundsam2bf357c2013-08-03 22:50:40 -0700307 ${prop.java_type.write_op(version, prop.priv_value, pub_type=False)};
Andreas Wundsam27303462013-07-16 12:52:35 -0700308//:: elif prop.is_length_value:
309 // ${prop.name} is length of variable message, will be updated at the end
Andreas Wundsam001b1822013-08-02 22:25:55 -0700310//:: if not msg.is_fixed_length:
311 int lengthIndex = bb.writerIndex();
312//:: #end
Andreas Wundsam27303462013-07-16 12:52:35 -0700313 ${prop.java_type.write_op(version, 0)};
Andreas Wundsam001b1822013-08-02 22:25:55 -0700314
Andreas Wundsam27303462013-07-16 12:52:35 -0700315//:: elif prop.is_field_length_value:
316//:: fields_with_length_member[prop.member.field_name] = prop.name
317 // ${prop.name} is length indicator for ${prop.member.field_name}, will be
318 // udpated when ${prop.member.field_name} has been written
319 int ${prop.name}Index = bb.writerIndex();
Andreas Wundsam001b1822013-08-02 22:25:55 -0700320 ${prop.java_type.write_op(version, 0, pub_type=False)};
Andreas Wundsam27303462013-07-16 12:52:35 -0700321//:: else:
322 // FIXME: todo write ${prop.name}
323//:: #endif
324//:: if prop.c_name in fields_with_length_member:
325//:: length_member_name = fields_with_length_member[prop.c_name]
326 // update field length member ${length_member_name}
327 int ${prop.name}Length = bb.writerIndex() - ${prop.name}StartIndex;
328 bb.setShort(${length_member_name}Index, ${prop.name}Length);
329//:: #endif
330//:: #endfor
331
Andreas Wundsam758c9cc2013-08-01 22:16:06 -0700332//:: if not msg.is_fixed_length:
Andreas Wundsam27303462013-07-16 12:52:35 -0700333 // update length field
334 int length = bb.writerIndex() - startIndex;
Andreas Wundsam5da68512013-10-22 22:18:00 -0700335 //:: if msg.align:
336 int alignedLength = ((length + ${msg.align-1})/${msg.align} * ${msg.align});
337 //:: #endif
338 bb.setShort(lengthIndex, ${"alignedLength" if msg.length_includes_align else "length"});
Andreas Wundsam758c9cc2013-08-01 22:16:06 -0700339 //:: if msg.align:
340 // align message to ${msg.align} bytes
Andreas Wundsam5da68512013-10-22 22:18:00 -0700341 bb.writeZero(alignedLength - length);
Andreas Wundsam758c9cc2013-08-01 22:16:06 -0700342 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -0700343//:: #end
344
345 }
346 }
347
Andreas Wundsameeefb552013-07-30 11:04:35 -0700348 @Override
Andreas Wundsamd7d5bb32013-07-30 12:26:31 -0700349 public String toString() {
350 StringBuilder b = new StringBuilder("${msg.name}(");
351 //:: for i, prop in enumerate(msg.data_members):
352 //:: if i > 0:
353 b.append(", ");
354 //:: #endif
355 b.append("${prop.name}=").append(${ "Arrays.toString(%s)" % prop.name if prop.java_type.is_array else prop.name });
356 //:: #endfor
357 b.append(")");
358 return b.toString();
359 }
360
361
362 @Override
Andreas Wundsameeefb552013-07-30 11:04:35 -0700363 public boolean equals(Object obj) {
364 if (this == obj)
365 return true;
366 if (obj == null)
367 return false;
368 if (getClass() != obj.getClass())
369 return false;
Yotam Harchola86e4252013-09-06 15:36:28 -0700370 //:: if len(msg.data_members) > 0:
Andreas Wundsameeefb552013-07-30 11:04:35 -0700371 ${msg.name} other = (${msg.name}) obj;
Yotam Harchola86e4252013-09-06 15:36:28 -0700372 //:: #endif
Andreas Wundsameeefb552013-07-30 11:04:35 -0700373
374 //:: for prop in msg.data_members:
375 //:: if prop.java_type.is_primitive:
376 if( ${prop.name} != other.${prop.name})
377 return false;
378 //:: elif prop.java_type.is_array:
379 if (!Arrays.equals(${prop.name}, other.${prop.name}))
380 return false;
Andreas Wundsamd7d5bb32013-07-30 12:26:31 -0700381 //:: else:
Andreas Wundsameeefb552013-07-30 11:04:35 -0700382 if (${prop.name} == null) {
383 if (other.${prop.name} != null)
384 return false;
385 } else if (!${prop.name}.equals(other.${prop.name}))
386 return false;
387 //:: #endif
388 //:: #endfor
389 return true;
390 }
391
392 @Override
393 public int hashCode() {
Yotam Harchola86e4252013-09-06 15:36:28 -0700394 //:: if len(msg.data_members) > 0:
Andreas Wundsameeefb552013-07-30 11:04:35 -0700395 final int prime = 31;
Yotam Harchola86e4252013-09-06 15:36:28 -0700396 //:: #endif
Andreas Wundsameeefb552013-07-30 11:04:35 -0700397 int result = 1;
398
399 //:: for prop in msg.data_members:
Andreas Wundsam2bf357c2013-08-03 22:50:40 -0700400 //:: if prop.java_type.pub_type == 'long':
401 result = prime * (int) (${prop.name} ^ (${prop.name} >>> 32));
Rob Vaterlausfeee3712013-09-30 11:24:19 -0700402 //:: elif prop.java_type.pub_type == 'boolean':
403 result = prime * result + (${prop.name} ? 1231 : 1237);
Andreas Wundsam2bf357c2013-08-03 22:50:40 -0700404 //:: elif prop.java_type.is_primitive:
Andreas Wundsameeefb552013-07-30 11:04:35 -0700405 result = prime * result + ${prop.name};
406 //:: elif prop.java_type.is_array:
407 result = prime * result + Arrays.hashCode(${prop.name});
408 //:: else:
409 result = prime * result + ((${prop.name} == null) ? 0 : ${prop.name}.hashCode());
410 //:: #endif
411 //:: #endfor
412 return result;
413 }
414
Andreas Wundsam27303462013-07-16 12:52:35 -0700415
416}