简体   繁体   English

如何在注释内部生成/声明注释字段?

[英]How can I generate/declare annotation field inside of Annotation?

I want to get something like this: 我想得到这样的东西:

public @interface Unfinished {
  String value();
   String value() default "someVal";
}

The problem is I cannot use JFieldVar because it looks like this: 问题是我无法使用JFieldVar,因为它看起来像这样:

String value; //no parentheses 
String value = "someVal"; //no parentheses, no "default", "=" sign

One possible way is to use jDefinedClass.direct: 一种可能的方法是使用jDefinedClass.direct:

annotationClass.direct("String value();")
annotationClass.direct("String value() default \"someVal\";")

But I don't like this approach. 但是我不喜欢这种方法。 I'd to use something similar to JFielVar. 我会使用类似于JFielVar的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM