Java自定义Annotation,通过反射解析Annotation(二)

2015-07-16 12:57:49 · 作者: · 浏览: 90
(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);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}