Sunday, 8 January 2012

How to define an annotation in java?

Just like creating a java interface, create f.e. a file with the following code:

public @interface ExampleAnnotation
// Property Definition here.

You have to add the following annotations in the definition:
  • Target - define where annotation can be added (methods, class, fields, properties, constructor, local variable, package, annotation type)
  •  Retention - where annotation will be available (only in source, in class definition, also in runtime)

No comments: