设为首页 加入收藏

TOP

Java自定义Annotation,通过反射解析Annotation(二)
2015-07-16 12:57:49 来源: 作者: 【 】 浏览:77
Tags:Java 定义 Annotation 通过 反射 解析
(String[] args) {
? ? ? ? for (Method method: AnnotationExample.class.getMethods()) {
? ? ? ? ? ? if (method.isAnnotationPresent(MethodInfo.class)) {
? ? ? ? ? ? ? ? for (Annotation annotation:method.getAnnotations()) {
? ? ? ? ? ? ? ? ? ? System.out.println(annotation + " in method:"+ method);
? ? ? ? ? ? ? ? }


? ? ? ? ? ? ? ? MethodInfo methodInfo = method.getAnnotation(MethodInfo.class);


? ? ? ? ? ? ? ? if ("1.0".equals(methodInfo.version())) {
? ? ? ? ? ? ? ? ? ? System.out.println("Method with revision no 1.0 = "
? ? ? ? ? ? ? ? ? ? ? ? ? ? + method);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Python日期操作学习心得 下一篇Google Guava 中的Monitor

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: