Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Field annotations #624
Let me know what you think of adding this functionality and if you have any better ideas for generate_java_fields.
This allows you to define an object in ruby and add field annotations. A use case is to create an object in ruby and pass it to a transformation library which uses fields and annotations for seralization.
Here is some documentation of java_field for the wiki (enclosed as a diff, as I couldn't find a better way to supply wiki changes as part of a pull request). I did not succeed in writing, and testing, a similar one for add_field_annotation. I don't know why my attempts failed, but I do have one question: what should add_field_annotation do if passed a name which does not exist? It seems to silently fail now.
[Note: I made comment on 48938ee which would be nice to be addressed]
I find this a reasonable starting point and I think we can merge this as-is, but I feel this is an incomplete feature as it would be nice if we could use the equivalent of java_signature() instead of the more procedural mechanism we have in place. It would see a day where we can have:
java_field '@Persistent @Synchronized Integer baz'
I suspect JavaSignatureParser needs some work to process field signatures but it is my hope eventually the above signature is the only way we add stuff. I mostly mention this is anyone wants to look into JavaSignatureParser and allow a more cut-and-paste signature format.