2010-02-01 65 views
0

我搜索了可能回答我的问题的示例,但找不到任何有用或完整的示例。我们是否需要访问者在java 6中进行注释处理?

+0

请邮寄到现在为止您编写的代码。 – jjj 2010-02-01 04:58:25

+0

我没有写任何代码,只是一个问题,有没有什么好的例子?谢谢。 – Allen 2010-02-01 05:48:30

+0

请提供更多关于你想要做什么的信息。你是指构建时注解处理(APT)?你在说什么访客? – 2010-02-01 08:23:23

回答

1

不,你不知道。

以下几行提供了Class的所有注释信息。同样,你可以用它来MethodField对象

Annotation[] annotations = someObject.getClass().getAnnotations(); 
YourAnnotation annotation = 
    someObject.getClass().getAnnotation(YourAnnotation.class); 
boolean annotationPresent = 
    someObject.getClass().isAnnotationPresent(YourAnnotation.class); 
相关问题