【发布时间】:2017-02-07 04:38:03
【问题描述】:
我在两个方法上有注释
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;
}
}
我希望能够写作
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") }
}
但 IntelliJ 告知我 Annotations are not allowed here 位于 annoArray 的位置。
有没有其他方法可以做到这一点?
【问题讨论】:
标签: java reflection annotations metaprogramming swagger