首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

诠注apt工具示例程序

2013-03-14 
注解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。

上面是我的一个方法,应该有更好的方法,希望大家可以分享。

热点排行