There must be a good book/PDF/HTML file that describes the essentials & good practices of annotations in Java. I sort of know what they are from other good Java books, but I'm looking for something that would teach me most of what I would need to know to make good use of them. (preferably in PDF/HTML so I can print it out & read at my leisure, book ok also but those go out of date so fast...)
Any recommendations?
edit: I found the Sun guides, as well as tutorials like these from O'Reilly and DevX, and the section of Effective Java that covers them... OK, so I know what they are and what tools to read them, but that doesn't tell me much about how they are put to use in practice. (other than a little bit in Effective Java and the O'Reilly article above that suggest their use in automated testing frameworks)
Annotation 2: @Override It is a marker annotation that can be used only on methods. A method annotated with @Override must override a method from a superclass. If it doesn't, a compile-time error will result (see this for example).
Annotation is defined like a ordinary Java interface, but with an '@' preceding the interface keyword (i.e., @interface ). You can declare methods inside an annotation definition (just like declaring abstract method inside an interface). These methods are called elements instead.
@Mapping annotation is used when the field names in the source and destination class differ. For example, The below code would map the fullName field in the source class object to the name field in the destination class object. This is particularly useful when you are mapping objects of two different classes.
Some opinions on annotations: http://web.archive.org/web/20120115164115/http://faler.wordpress.com/2007/11/21/when-to-use-and-not-to-use-java-annotations
This guy is very much against them: https://web.archive.org/web/20060702222249/http://www.softwarereality.com/programming/annotations.jsp
Best Practices: http://willcode4beer.com/opinion.jsp?set=annotations_gotchas_best_practices
Hope this helps. Let us know what you find.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With