注解之Documented
Documented源码
/**
* Indicates that annotations with a type are to be documented by javadoc
* and similar tools by default. This type should be used to annotate the
* declarations of types whose annotations affect the use of annotated
* elements by their clients. If a type declaration is annotated with
* Documented, its annotations become part of the public API
* of the annotated elements.
*
* 指示带有类型的注释在默认情况下由javadoc和类似工具记录。
* 这种类型应该用于注释类型的声明,这些类型的注释会影响其客户端对已注释元素的使用。
* 如果用Documented注释类型声明,则其注释将成为已注释元素的公共API的一部分。
*
* @author Joshua Bloch
* @since 1.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Documented {
}
解析
- @Documented - 在生成javadoc的时候就会把注解给显示出来。
- @Retention(RetentionPolicy.RUNTIME) - VM在运行时也不丢弃该注解。
- @Target(ElementType.ANNOTATION_TYPE) - 作用范围为注解
总结
- 该注解在javadoc中显示出来
- 该注解一直存在(生命周期)
- 该注解作用在注解上