我搜索了可能回答我的问题的示例,但找不到任何有用或完整的示例。
最佳答案
不,你不知道。
以下几行为您提供了类
的所有注释信息。同样,您可以将其用于 Method
和 Field
对象
Annotation[] annotations = someObject.getClass().getAnnotations();
YourAnnotation annotation =
someObject.getClass().getAnnotation(YourAnnotation.class);
boolean annotationPresent =
someObject.getClass().isAnnotationPresent(YourAnnotation.class);
关于java - 在java 6中我们需要访问者来进行注释处理吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2174724/