Monday 30 June 2014

@Documented

@Documented is a meta-annotation. You apply @Documented when defining an annotation, to ensure that classes using your annotation show this in their generated JavaDoc.

Example : Lets generate java doc for a java file using Annotations and using javadoc.

Using Documentation Comments
/**
 *  Author : Krishna
 *  Date : June 17th 2014
 *  Current Version : 1
 *  Last Modified : June 17th 2014
 *  Reviewers : Raghav
 */
public class SampleFile{

}
Run the below command
javadoc SampleFile.java.

You can get the documentation like below.

Using @Documented
import java.lang.annotation.*;

@Documented
public @interface AuthorDetails{
 String author();
 String date();
 int currentVersion() default 1;
 String lastModified() default "N/A";
 String[] Reviewers();
}

@AuthorDetails(
 author = "Krishna",
 date = "June 17th 2014",
 currentVersion = 1,
 lastModified = "June 17th 2014",
 Reviewers = {"Raghav", "Krishna"}
)
public class SampleFile{

}

Run the below command
javadoc SampleFile.java.

You can get the documentation like below.

Annotation @Documented is used to make the information in @AuthorDetails appear in Javadoc-generated documentation.



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment