blob: c7aa3a0b60a934921a55b370a2701fd20a9d68d1 [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:
Yotam Harcholf25e8142013-09-09 14:30:13 -07003//:: getter_template_file_name = "%s/custom/%s_%s.java" % (template_dir, msg.name if not builder else msg.name + '.Builder', prop.getter_name)
4//:: if os.path.exists(getter_template_file_name):
5//:: include(getter_template_file_name, msg=msg, builder=builder, has_parent=has_parent)
Yotam Harcholf25e8142013-09-09 14:30:13 -07006
Yotam Harchol0936bfb2013-09-10 16:34:20 -07007//:: else:
Andreas Wundsam27303462013-07-16 12:52:35 -07008 @Override
Andreas Wundsam99e931d2013-08-22 07:53:53 -07009 public ${prop.java_type.public_type} ${prop.getter_name}()${ "" if prop in msg.members else "throws UnsupportedOperationException"} {
Andreas Wundsam27303462013-07-16 12:52:35 -070010//:: if prop in msg.members:
11//:: version_prop = msg.get_member(prop.name)
12//:: if version_prop.is_fixed_value:
13 return ${version_prop.enum_value};
14//:: elif version_prop.is_length_value:
15 // FIXME: Hacky and inperformant way to determine a message length. Should be replaced with something better
16 ChannelBuffer c = new LengthCountingPseudoChannelBuffer();
17 WRITER.write(c, ${ "this" if not builder else "({0}) this.getMessage()".format(msg.name) });
18 return c.writerIndex();
19//:: else:
20 return ${version_prop.name};
21//:: #endif
22//:: else:
23 throw new UnsupportedOperationException("Property ${prop.name} not supported in version #{version}");
24//:: #endif
25 }
Yotam Harcholf25e8142013-09-09 14:30:13 -070026//:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070027
28//:: if generate_setters and prop.is_writeable:
Yotam Harcholf25e8142013-09-09 14:30:13 -070029 //:: setter_template_file_name = "%s/custom/%s_%s.java" % (template_dir, msg.name if not builder else msg.name + '.Builder', prop.setter_name)
30 //:: if os.path.exists(setter_template_file_name):
31 //:: include(setter_template_file_name, msg=msg, builder=builder, has_parent=has_parent)
Yotam Harchol0936bfb2013-09-10 16:34:20 -070032
Yotam Harcholf25e8142013-09-09 14:30:13 -070033 //:: else:
Andreas Wundsam27303462013-07-16 12:52:35 -070034 @Override
Andreas Wundsam99e931d2013-08-22 07:53:53 -070035 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 -070036 //:: if prop in msg.members:
Andreas Wundsam27303462013-07-16 12:52:35 -070037 this.${prop.name} = ${prop.name};
38 this.${prop.name}Set = true;
39 return this;
Yotam Harcholf25e8142013-09-09 14:30:13 -070040 //:: else:
Andreas Wundsam27303462013-07-16 12:52:35 -070041 throw new UnsupportedOperationException("Property ${prop.name} not supported in version #{version}");
Yotam Harcholf25e8142013-09-09 14:30:13 -070042 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070043 }
Yotam Harcholf25e8142013-09-09 14:30:13 -070044 //:: #endif
45 //:: #endif
Andreas Wundsam27303462013-07-16 12:52:35 -070046//:: #endfor