Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 1 | //:: for prop in msg.interface.members: |
| 2 | @Override |
| 3 | public ${prop.java_type.public_type} get${prop.title_name}()${ "" if prop in msg.members else "throws UnsupportedOperationException"} { |
| 4 | //:: if prop in msg.members: |
| 5 | //:: version_prop = msg.get_member(prop.name) |
| 6 | //:: if version_prop.is_fixed_value: |
| 7 | return ${version_prop.enum_value}; |
| 8 | //:: elif version_prop.is_length_value: |
| 9 | // FIXME: Hacky and inperformant way to determine a message length. Should be replaced with something better |
| 10 | ChannelBuffer c = new LengthCountingPseudoChannelBuffer(); |
| 11 | WRITER.write(c, ${ "this" if not builder else "({0}) this.getMessage()".format(msg.name) }); |
| 12 | return c.writerIndex(); |
| 13 | //:: else: |
| 14 | return ${version_prop.name}; |
| 15 | //:: #endif |
| 16 | //:: else: |
| 17 | throw new UnsupportedOperationException("Property ${prop.name} not supported in version #{version}"); |
| 18 | //:: #endif |
| 19 | } |
| 20 | |
| 21 | //:: if generate_setters and prop.is_writeable: |
| 22 | @Override |
| 23 | public ${msg.interface.name}.Builder set${prop.title_name}(${prop.java_type.public_type} ${prop.name})${ "" if prop in msg.members else " throws UnsupportedOperationException"} { |
| 24 | //:: if prop in msg.members: |
| 25 | this.${prop.name} = ${prop.name}; |
| 26 | this.${prop.name}Set = true; |
| 27 | return this; |
| 28 | //:: else: |
| 29 | throw new UnsupportedOperationException("Property ${prop.name} not supported in version #{version}"); |
| 30 | //:: #endif |
| 31 | } |
| 32 | //:: #endif |
| 33 | //:: #endfor |