private void findReferencesBean ( Object base , Class < ? > declaredClass , Map < Object , Integer > objects , SerIterator parentIterator ) { if ( base == null ) { return ; } // has this object been seen before, if so no need to check it again int result = objects . compute ( base , BeanReferences :: incrementOrOne ) ; if ( result > 1 ) { return ; } if ( base instanceof Bean ) { addClassInfo ( base , declaredClass ) ; Bean bean = ( Bean ) base ; if ( settings . getConverter ( ) . isConvertible ( bean . getClass ( ) ) ) { return ; } for ( MetaProperty < ? > prop : bean . metaBean ( ) . metaPropertyIterable ( ) ) { if ( settings . isSerialized ( prop ) ) { Object value = prop . get ( bean ) ; Class < ? > type = SerOptional . extractType ( prop , base . getClass ( ) ) ; if ( value != null ) { SerIterator itemIterator = settings . getIteratorFactory ( ) . create ( value , prop , bean . getClass ( ) ) ; if ( itemIterator != null ) { if ( itemIterator . metaTypeRequired ( ) ) { objects . compute ( itemIterator . metaTypeName ( ) , BeanReferences :: incrementOrOne ) ; } findReferencesIterable ( itemIterator , objects ) ; } else { findReferencesBean ( value , type , objects , null ) ; } } else { // In case it's a null value or optional field addClassInfo ( type , type ) ; } } } } else if ( parentIterator != null ) { SerIterator childIterator = settings . getIteratorFactory ( ) . createChild ( base , parentIterator ) ; if ( childIterator != null ) { findReferencesIterable ( childIterator , objects ) ; } else { addClassInfo ( base , declaredClass ) ; } } else { addClassInfo ( base , declaredClass ) ; } }
recursively find the references