以下是注释代码
public @interface ColumnName {
String value();
String datatype();
}
Run Code Online (Sandbox Code Playgroud)
我想做datatype一个可选参数,例如
@ColumnName(value="password")
Run Code Online (Sandbox Code Playgroud)
应该是一个有效的代码.
Rid*_*del 118
/**
* 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]";
}
Run Code Online (Sandbox Code Playgroud)
Joh*_*ter 34
要使其可选,您可以为其指定一个默认值:
public @interface ColumnName {
String value();
String datatype() default "String";
}
Run Code Online (Sandbox Code Playgroud)
然后在使用Annotation时不需要指定它.
| 归档时间: |
|
| 查看次数: |
72492 次 |
| 最近记录: |