/** * Created by hero on 17-3-26. * 参考http://www.mkyong.com/java/java-custom-annotations-example/ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public@interface Night {
/** * Created by hero on 17-3-26. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)// class level public@interface NightFire { publicenumLight { LOW, MEDIUM, HIGH }
publicenumRetentionPolicy { /** * Annotations are to be discarded by the compiler. */ SOURCE,
/** * Annotations are to be recorded in the class file by the compiler * but need not be retained by the VM at run time. This is the default * behavior. */ CLASS,
/** * Annotations are to be recorded in the class file by the compiler and * retained by the VM at run time, so they may be read reflectively. * * @see java.lang.reflect.AnnotatedElement */ RUNTIME }