以下是注释代码
public @interface ColumnName {
String value();
String datatype();
}
我想让 datatype
成为可选参数,例如
@ColumnName(value="password")
应该是一个有效的代码。
最佳答案
似乎是 official documentation 中的第一个示例说明一切......
/**
* Describes the Request-For-Enhancement(RFE) that led
* to the presence of the annotated API element.
*/
public @interface RequestForEnhancement {
int id();
String synopsis();
String engineer() default "[unassigned]";
String date() default "[unimplemented]";
}
关于java - 如何为自己的注释创建可选参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3520375/