1 22 23 package org.jboss.test.visitor; 24 25 import java.lang.reflect.Field ; 26 import java.lang.reflect.Method ; 27 28 35 public class TypeHierarchyTraversal 36 { 37 42 public static void visit(Class rootClass, TypeVisitor visitor) 43 { 44 Class clazz = rootClass; 45 while( clazz != null ) 46 { 47 processType(clazz, visitor); 48 clazz = clazz.getSuperclass(); 49 } 50 } 51 static void processType(Class clazz, TypeVisitor visitor) 52 { 53 visitor.visitClass(clazz); 54 Class [] ifaces = clazz.getInterfaces(); 55 visitor.visitInterfaces(ifaces); 56 Method [] methods = clazz.getDeclaredMethods(); 57 visitor.visitMethods(methods); 58 Field [] fields = clazz.getDeclaredFields(); 59 visitor.visitFields(fields); 60 } 61 } 62 | Popular Tags |