查找与注释匹配的特定类的方法

时间:2016-01-18 17:46:38

标签: java google-reflections

我有两个注释,我们称它们为@Foo和@Bar。 @Foo是一个类(aka类型)级别的注释,而@Bar是一个方法级注释。我的意图是给定一个@Foo类,迭代所有的@Bar方法。最合适的方法是什么?我目前正在使用Google Reflections API for Java。

感谢。

1 个答案:

答案 0 :(得分:0)

Wero的评论有效: “你可以简单地使用fooClass.getDeclaredMethods()来枚举(声明的)方法和method.getAnnotation(Bar.class)!= null来过滤条形方法”