【发布时间】:2019-10-25 10:56:47
【问题描述】:
我有一个参数化注释(在本例中为@MiTag1)。我想创建一个新的注释(@MiTag2),扩展@MiTag1和其他注释,我希望@MiTag1的值被@MiTag2的值“扩展”
在我的代码示例中,@MiTag2("bla") 必须与 @MiTag1("bla") 相同,但在 @MiTag2 中没有硬编码“bla”。
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MiTag1 {
/**
* The resource key.
*
* @see Resources
*/
String value();
}
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@MiTag1(value = THIS.VALUE)
public @interface MiTag2 {
/**
* The resource key.
*
* @see Resources
*/
String value();
}
【问题讨论】:
标签: java inheritance annotations