Rob Williams is a probabilistic Lean coder of Java and Objective-C. Rob is a DZone MVB and is not an employee of DZone and has posted 170 posts at DZone. You can read more from them at their website. View Full User Profile

An Eclipse Template for Creating Annotations

05.16.2011
| 5904 views |
  • submit to reddit

If/when you start doing Java EE 6 (spec lead from Oracle insisted that I use this means of referring to the latest release, by telling me that JEE6 does not exist, which I took some philosophical amusement in, given that language is not often about an arbiter making an existential argument for the referent), you will be making a lot of annotations. Repositories, qualifiers for injections, etc.

The Weld archetype comes with a bunch in place that I noted use static imports for the constants that are required. If you then go and make your own, since eclipse‘s import mechanism is still not bright enough to deal with static imports, you will no doubt end up with ElementType and RetentionPolicy clogging up your already seriously ugly declaration space.

So here is a template that just makes the whole annotation, including the package statement, and then drops you into the JavaDoc block where you can state your intentions and move on.

XML of eclipse template

 

From http://www.jroller.com/robwilliams/entry/an_eclipse_template_for_creating

Published at DZone with permission of Rob Williams, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)