简体   繁体   中英

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:

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

One possible way is to use 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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