Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

best (or at least good) guide to Java annotations [closed]

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)

like image 977
Jason S Avatar asked Dec 24 '08 19:12

Jason S


People also ask

Do you know any annotation in Java Please explain at least 2 annotations?

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).

What is @interface annotation in Java?

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.

What is @mapping annotation Java?

@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.


1 Answers

  • 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.

like image 143
troyal Avatar answered Sep 28 '22 11:09

troyal