注解之Documented

4 篇文章 0 订阅
1 篇文章 0 订阅
本文深入解析了Java中的@Documented注解,它指示注释在默认情况下应被javadoc等工具记录。@Documented确保注解成为公共API的一部分,并在运行时保留。该注解适用于注解类型,帮助开发者管理和展示代码的API接口。
摘要由CSDN通过智能技术生成

注解之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中显示出来
  • 该注解一直存在(生命周期)
  • 该注解作用在注解上
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值