public static void visit ( Object instance , TypeToken < ? > inspectType , Visitor firstVisitor , Visitor ... moreVisitors ) { try { List < Visitor > visitors = ImmutableList . < Visitor > builder ( ) . add ( firstVisitor ) . add ( moreVisitors ) . build ( ) ; for ( TypeToken < ? > type : inspectType . getTypes ( ) . classes ( ) ) { if ( Object . class . equals ( type . getRawType ( ) ) ) { break ; } for ( Field field : type . getRawType ( ) . getDeclaredFields ( ) ) { if ( ! field . isAccessible ( ) ) { field . setAccessible ( true ) ; } for ( Visitor visitor : visitors ) { visitor . visit ( instance , inspectType , type , field ) ; } } for ( Method method : type . getRawType ( ) . getDeclaredMethods ( ) ) { if ( ! method . isAccessible ( ) ) { method . setAccessible ( true ) ; } for ( Visitor visitor : visitors ) { visitor . visit ( instance , inspectType , type , method ) ; } } } } catch ( Exception e ) { throw Throwables . propagate ( e ) ; } }
Inspect all members in the given type . Fields and Methods that are given to Visitor are always having accessible flag being set .