The ‘@documented’ annotation indicates that an annotation with this type should be documented by the javadoc tool. By default, annotations are not included in javadoc. But if @Documented is used, it then will be processed by javadoc-like tools and the annotation type information will also be included in the generated document.
1 2 3 4 5 6 7 8 9 |
package www.technicaljungle.com; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) public @interface RetentionAnnotationInterface { String doSomething(); } |
1 2 3 4 5 6 7 8 9 10 |
package www.technicaljungle.com; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Target; @Documented public @interface DocumentedAnnotationInterface { String doSomething(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
package www.technicaljungle.com; @TargetAnnotationInterface(doSomething = "Welcome") public class DocumentedAnnotationSample{ public static void main(String []args) { new DocumentedAnnotationSample().doSomething(); new DocumentedAnnotationSample().doSomethingDocumented(); } @RetentionAnnotationInterface(doSomething = "This will not be documented") public void doSomething() { System.out.println("www.TechnicalJungle.com - @RetentionAnnotationInterface"); } @DocumentedAnnotationInterface(doSomething = "This will be documented") public void doSomethingDocumented() { System.out.println("www.TechnicalJungle.com - @DocumentedAnnotationInterface"); } } |
Have a look on method “doSomethingDocumented()“. This is documented by java doc tool.
@Annotations