如何打印不同注释的注释值?
我有以下两个注解
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Author
{
String name() default "--Unknown--";
String date() default "--Unknown--";
}
和
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Revision
{
int version() default 0;
String modifiedBy() default "--Unknown--";
}
现在一个类同时使用这个注释,在这个类中我想显示两个注释的注释值
@Author(
name = "Panther",
date = "22.04.2013"
)
@Revision(
version = 2,
modifiedBy = "Black",
)
public class AnnotationTest
{
public static void main(String[] args)
{
AnnotationTest b = new AnnotationTest();
for(Annotation a : AnnotationTest.class.getDeclaredAnnotations())
{
// for Author display name and date
// for revision display version and modifiedBy
}
}
}
有什么办法吗?