lundi 6 février 2017

Unable to declare array of annotations

I have annotations on two methods

public class Question {

    @AnnotationA(value = { @AnnotationB(message = "One"), @AnnotationB(message = "Two") })
    public int methodOne() {
        return 1;
    }

    @AnnotationA(value = { @AnnotationB(message = "One"), @AnnotationB(message = "Two") })
    public int methodTwo() {
        return 2;
    }
}

and I would like to be able to write

public class Question {

    @AnnotationA(value = annoArray)
    public int methodOne() {
        return 1;
    }

    @AnnotationA(value = annoArray)
    public int methodTwo() {
        return 2;
    }

    public AnnotationB[] annoArray = { @AnnotationB(message = "One"), @AnnotationB(message = "Two") }
}

but I am informed by IntelliJ that Annotations are not allowed here at the location of the annoArray.

Is there a different way to do this?





Aucun commentaire:

Enregistrer un commentaire