public void walk ( Object root , Class [ ] skip , Visitor visitor ) { Deque stack = new LinkedList ( ) ; stack . add ( root ) ; while ( ! stack . isEmpty ( ) ) { Object current = stack . removeFirst ( ) ; if ( current == null || _objVisited . containsKey ( current ) ) { continue ; } final Class clazz = current . getClass ( ) ; ClassInfo classInfo = getClassInfo ( clazz , skip ) ; if ( classInfo . _skip ) { // Do not process any classes that are assignableFrom the skip classes list. continue ; } _objVisited . put ( current , null ) ; visitor . process ( current ) ; if ( clazz . isArray ( ) ) { int len = Array . getLength ( current ) ; Class compType = clazz . getComponentType ( ) ; if ( ! compType . isPrimitive ( ) ) { // Speed up: do not walk primitives ClassInfo info = getClassInfo ( compType , skip ) ; if ( ! info . _skip ) { // Do not walk array elements of a class type that is to be skipped. for ( int i = 0 ; i < len ; i ++ ) { Object element = Array . get ( current , i ) ; if ( element != null ) { // Skip processing null array elements stack . add ( Array . get ( current , i ) ) ; } } } } } else { // Process fields of an object instance if ( current instanceof Collection ) { walkCollection ( stack , ( Collection ) current ) ; } else if ( current instanceof Map ) { walkMap ( stack , ( Map ) current ) ; } else { walkFields ( stack , current , skip ) ; } } } }
Traverse the object graph referenced by the passed in root .