[英]Java: how to set default value to annotation with another annotation as its attribute?
I have an annotation with 3 attributes: 我有一个带有3个属性的注释:
public @interface Date {
int day() default 1;
int month() default 1;
int year() default 2000;
}
And annotation that uses previous annotation as attribute: 以及使用先前注释作为属性的注释:
public @interface Author {
String name();
Date date(); //default value here
}
How to set default value for attribute date
? 如何设置属性
date
默认值?
You do this by providing a default annotaion... 您可以通过提供默认注释来完成此操作...
For example: 例如:
public @interface Author {
String name();
Date date() default @Date(year=2014);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.