我有一个Java元注解这样的Java元注解在运行时
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.ANNOTATION_TYPE })
public @interface Qualifier {
}
然后我还有一个注释:
@Qualifier
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE })
public @interface LeafEntity {
String name() default "";
}
在运行时,我可以提取使用
getClass().getAnnotation(LeafEntity.class);
的LeafEntity注释
不过,我想知道是否有可能访问有关限定符什么?我的意思是,如果您无法访问注释,注释的目的是什么?
我已经尝试了所有的以下内容:
getClass().getAnnotation(Qualifier.class);
getClass().getAnnotation(LeafEntity.class).getClass().getAnnotation(Qualifier.class);
getClass().getAnnotation(LeafEntity.class) instanceof Qualifier.class;
如果有人知道如何访问限定符注解我将不胜感激的例子..
的原因,这是很重要的是,我有一个基地注释称为Qualifier。我希望允许我的用户定义他们喜欢的任何注释,只需将Qualifier注释应用到它。然后,我将扫描该类以查找由Qualifier批注注释的任何批注。但是如果我无法访问或识别Qualifier注释,这是不可能的。
在此先感谢。
是的,这是票。谢谢。 – user620165 2011-04-12 10:27:33