blob: 030388cc47d8f048f7b3bee4f28965a8a9d887c8 [file] [log] [blame]
Yotam Harcholf25e8142013-09-09 14:30:13 -07001//:: import os
Andreas Wundsam27303462013-07-16 12:52:35 -07002//:: for prop in msg.interface.members:
Andreas Wundsam4b8661f2013-11-05 17:17:28 -08003//:: if hasattr(prop, "custom_template") and prop.custom_template != None:
4//:: getter_template_file_name = "%s/custom/%s" % (template_dir, prop.custom_template(builder=builder))
5//:: else:
6//:: getter_template_file_name = "%s/custom/%s_%s.java" % (template_dir, msg.name if not builder else msg.name + '.Builder', prop.getter_name)
7//:: #endif
8//:: if os.path.exists(getter_template_file_name):
9//:: include(getter_template_file_name, msg=msg, builder=builder, has_parent=has_parent, prop=prop)
10//:: else:
Andreas Wundsam27303462013-07-16 12:52:35 -070011 @Override
Andreas Wundsam99e931d2013-08-22 07:53:53 -070012 public ${prop.java_type.public_type} ${prop.getter_name}()${ "" if prop in msg.members else "throws UnsupportedOperationException"} {
Andreas Wundsam27303462013-07-16 12:52:35 -070013//:: if prop in msg.members:
14//:: version_prop = msg.get_member(prop.name)
15//:: if version_prop.is_fixed_value:
16 return ${version_prop.enum_value};
17//:: elif version_prop.is_length_value:
18 // FIXME: Hacky and inperformant way to determine a message length. Should be replaced with something better
19 ChannelBuffer c = new LengthCountingPseudoChannelBuffer();
20 WRITER.write(c, ${ "this" if not builder else "({0}) this.getMessage()".format(msg.name) });
21 return c.writerIndex();
22//:: else:
23 return ${version_prop.name};
24//:: #endif
25//:: else:
26 throw new UnsupportedOperationException("Property ${prop.name} not supported in version #{version}");
27//:: #endif
28 }
Yotam Harcholf25e8142013-09-09 14:30:13 -070029//:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070030
31//:: if generate_setters and prop.is_writeable:
Yotam Harcholf25e8142013-09-09 14:30:13 -070032 //:: setter_template_file_name = "%s/custom/%s_%s.java" % (template_dir, msg.name if not builder else msg.name + '.Builder', prop.setter_name)
33 //:: if os.path.exists(setter_template_file_name):
34 //:: include(setter_template_file_name, msg=msg, builder=builder, has_parent=has_parent)
Yotam Harchol0936bfb2013-09-10 16:34:20 -070035
Yotam Harcholf25e8142013-09-09 14:30:13 -070036 //:: else:
Andreas Wundsam27303462013-07-16 12:52:35 -070037 @Override
Andreas Wundsam99e931d2013-08-22 07:53:53 -070038 public ${msg.interface.name}.Builder ${prop.setter_name}(${prop.java_type.public_type} ${prop.name})${ "" if prop in msg.members else " throws UnsupportedOperationException"} {
Yotam Harcholf25e8142013-09-09 14:30:13 -070039 //:: if prop in msg.members:
Andreas Wundsam27303462013-07-16 12:52:35 -070040 this.${prop.name} = ${prop.name};
41 this.${prop.name}Set = true;
42 return this;
Yotam Harcholf25e8142013-09-09 14:30:13 -070043 //:: else:
Andreas Wundsam27303462013-07-16 12:52:35 -070044 throw new UnsupportedOperationException("Property ${prop.name} not supported in version #{version}");
Yotam Harcholf25e8142013-09-09 14:30:13 -070045 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070046 }
Yotam Harcholf25e8142013-09-09 14:30:13 -070047 //:: #endif
48 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070049//:: #endfor