As marked in the comments as well, the default value ""
for the annotation key owners
creates an array with an element that's an empty string. You can also put a single string "default"
in there as well which would lead to creating an array with only value "default"
OR
{}
simply for an empty array if the need be.
To test this you can mark the annotation with Runtime retention policy as :
@Unfinished("Just articleware")
@Retention(RetentionPolicy.RUNTIME) // mark with Runtime retention policy
public @interface Unfinished {
enum Priority {LOW, MEDIUM, HIGH}
String value();
String[] owners() default "";
Priority priority() default Priority.MEDIUM;
}
Annotate a class with this
@Unfinished(value = "")
public class AnnotatedClass {
public static void main(String[] args) {
System.out.println("");
}
}
and then use Reflection to get the values of the keys of Unfinished
as :
public static void main(String[] args) throws Exception {
System.out.println("Testing...");
Class<AnnotatedClass> obj = AnnotatedClass.class;
if (obj.isAnnotationPresent(Unfinished.class)) {
Annotation annotation = obj.getAnnotation(Unfinished.class);
Unfinished unfinished = (Unfinished) annotation;
System.out.println(Arrays.toString(unfinished.owners()));
}
}