Change from :
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
String value();
}
To:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
WeekDay value();
}
And use it like this:
@MyAnnotation(WeekDay.SUNDAY)
It will also work if you pass a string literal to your current annotation. Marking your method as final won't work because final on methods only prevents you from overriding it, not returning a constant value. Example:
public final String getString() {
String[] strings = { "A", "B" };
return strings[new Random().nextInt(2)]; // returned value is not the same
}