[ https://issues.apache.org/jira/browse/THRIFT-139?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Reiss resolved THRIFT-139. -------------------------------- Resolution: Fixed > Add reflection-like features to generated classes > ------------------------------------------------- > > Key: THRIFT-139 > URL: https://issues.apache.org/jira/browse/THRIFT-139 > Project: Thrift > Issue Type: New Feature > Components: Compiler (Java) > Reporter: Bryan Duxbury > Assignee: Bryan Duxbury > Attachments: thrift-139-v2.patch, thrift-139.patch > > > There are a few things I think would increase the usability of generated > classes: > * Contain named constants for each field name with its field ID. This would > allow you to do stuff like MyClass.SOME_FIELD_NAME and get the field ID and > use it elsewhere. (We use this as a selector for which field in a union-like > structure is selected.) You could also use the named constants in the > generated code's read and write methods to more clearly indicate which fields > are being read or written. > * Setter and getter methods by field ID. You could have a signature like > "public object getFieldValue(int fieldID)" and "public void setFieldValue(int > fieldID, Object value)". This would allow you to write code that was generic > over different fields of the same type and only took the field ID as a > parameter, for instance. > Would other people be interested in capabilities like this? I'm sure we can > think of other things we'd like to add as well. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.