I want to have an Integer Array as input in annotation interface, something like this.
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface CheckAccess {
AccessType accessType() default AccessType.ALL;
Integer[] permissions();
}
so that while providing the input, I can use some constant having integer values. Like this:-
@CheckAccess(permissions={CAN_READ, CAN_WRITE})
CAN_READ = 1;
CAN_WRITE=2;
How can I achieve this? Because when I set Integer[] it throws compilation error but works fine for String[].
Error:(15, 12) java: invalid type for element {0} of annotation typeint[]is the simplest solution.