PDA

View Full Version : New ModelData Annotation for Generating Implementations (Ant & Maven Support)



joshuadmorris
24 Jul 2009, 11:25 AM
I use the ModelData interface for all my DTOs and UI model objects since it is what GXT uses for the widget's backing model. I have been manually implementing this interface as I do not want to deal with a wrapper. I want to use my object in my code and not constantly be casting and fetching to use it. Not only does this keep my code cleaner and more readable, but the refactoring, searching, encapsulation, and reference checking tools in most modern IDEs simply do not play well with wrappers. However, I eventually got tired of so much manual, menial coding and decided to create my own annotation processor to automatically implement the ModelData interface for me.

I created an open source (Apache 2.0 License) project, unitt:modeldata (http://code.google.com/p/unitt/wiki/modeldata), to share this functionality with the greater GXT community. The project allows you to simply mark your DTO or model class with a single annotation and let the build process generate the required source code for you. This way you are always using an instance of your object. It generates the source code so feel free to extend or modify the generated class if you wish to override its default behavior. It should work with any overloaded setters, primitives, or even nested/child objects. So far, it works just fine in all of my personal projects as well as all our projects at work. Let me know if you have any issues. For further information, see the Google code project: unitt:modeldata. (http://code.google.com/p/unitt/wiki/modeldata)

Let me know if you have any ideas or suggestions for improvements. There is an issue tracking system built into the Google project site so feel free to post bothersome issues there!