@Todo("Just articleware")public @interface Todo{public enum Priority { LOW, MEDIUM, HIGH }String value();String[] owners() default "";Priority priority() default Priority.MEDIUM;}
@Todo(value="Class scope",priority=Unfinished.Priority.LOW)public class TodoDemo {@Todo("Constructor scope")//通过快捷方式,设置value的值public TodoDemo() { }@Todo(owner="Jason", value="Method scope")public void foo() { }}
package com.robin;import java.lang.annotation.*;@Todo("Just articleware")@Documentedpublic @interface Todo{ ...
package com.robin;import java.lang.annotation.*;@Todo("Just articleware")@Documented@Retention(RetentionPolicy.RUNTIME)public @interface Todo{ ...
- ElementType.TYPE (class, interface, enum)
- ElementType.FIELD (instance variable)
- ElementType.METHOD ElementType.PARAMETER
- ElementType.CONSTRUCTOR
- ElementType.LOCAL_VARIABLE
- ElementType.ANNOTATION_TYPE (应用于另一个注解上)
- ElementType.PACKAGE
package com.robin;import java.lang.annotation.*;@Todo("Just articleware")@Documented@Retention(RetentionPolicy.RUNTIME)@Target({ElementType.TYPE,ElementType.METHOD,ElementType.CONSTRUCTOR,ElementType.ANNOTATION_TYPE,ElementType.PACKAGE})public @interface Todo{ ...
package com.robin;import java.lang.annotation.*;@Todo("Just articleware")@Documented@Retention(RetentionPolicy.RUNTIME)@Target({ElementType.TYPE,ElementType.METHOD,ElementType.CONSTRUCTOR,ElementType.ANNOTATION_TYPE,ElementType.PACKAGE})@Inheritedpublic @interface Todo{public enum Priority { LOW, MEDIUM, HIGH }String value();String[] owners() default "";Priority priority() default Priority.MEDIUM;}
联系客服