package java.lang.annotation;
/**
* 代码注释文档化(javadoc),即:归档时,注释也编译
* @author TCM
* @create 2017年10月17日下午4:47:54
* @since 1.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Documented {
}
package java.lang.annotation;
/**
* 目的:注释要保留多久
* 注意:1.没有此注解时,默认RetentionPolicy.CLASS
* 2.只有元注释类型直接用于注释时,Target元注释才有效
* 3.RetentionPolicy保留策略
* @author TCM
* @create 2017年10月17日下午4:51:58
* @see RetentionPolicy
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Retention {
RetentionPolicy value();
}
package java.lang.annotation;
/**
* 注释保留策略,结合{@link Retention}使用
* @author TCM
* @create 2017年10月17日下午5:02:01
* @since 1.5
*/
public enum RetentionPolicy {
/**
* 注释在源码中,编译时丢弃
*/
SOURCE,
/**
* 编译时,注释也编译进去,但是JVM运行时不保留
* 默认保留策略
*/
CLASS,
/**
* 编译和JVM运行时,注释也添加进去
* 通过反射机制读取注释
* @see java.lang.reflect.AnnotatedElement
*/
RUNTIME
}