Custom Annotation
Overview about custom annotation.
About
How to create and use custom annotations ?
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyCustomAnnotation {
String value() default ""; // A method with a String return type
int number() default 0; // A method with an int return type
boolean enabled() default true; // A method with a boolean return type
Class<?> type() default Void.class; // A method with a Class return type
Class<? extends SomeFactory> someFactory(); // A method with a Class return type
MyEnum enumValue() default MyEnum.DEFAULT; // A method with an enum return type
String[] arrayValue() default {}; // A method with an array return type
}
enum MyEnum {
DEFAULT,
OPTION1,
OPTION2
}Examples


Last updated