诠注apt工具示例程序
注解apt工具示例程序for?(MethodDeclaration?m?:?typeDel.getMethods())?{??????if?(m.getModifiers().con
注解apt工具示例程序
for?(MethodDeclaration?m?:?typeDel.getMethods())?{??????if?(m.getModifiers().contains(Modifier.PUBLIC)??????????????&&?!(m.getModifiers().contains(Modifier.STATIC)))?{??????????interfaceMethods.add(m);??????}??}??
?如果使用书中的代码是无法得到预期结果的,我使用JDK1.6,不知道JDK1.5是否可以。在JDK1.6中,getModifiers()返 回Collection<Modifier>类型,而Modifier类中的静态常量(PUBLIC、STATIC等)是int类型,因此书 中代码总会返回false。
上面是我的一个方法,应该有更好的方法,希望大家可以分享。