public List < Bean > getBeans ( ) { Map < BeanId , Bean > referenceMap = new HashMap <> ( ) ; List < Bean > result = new ArrayList <> ( ) ; for ( HBeanRow row : inital . keySet ( ) ) { Bean bean = row . getBean ( ) ; result . add ( bean ) ; referenceMap . put ( bean . getId ( ) , bean ) ; } for ( HBeanRow row : references . keySet ( ) ) { Bean bean = row . getBean ( ) ; referenceMap . put ( bean . getId ( ) , bean ) ; } for ( Bean bean : referenceMap . values ( ) ) { for ( BeanId id : bean . getReferences ( ) ) { Bean ref = referenceMap . get ( id ) ; id . setBean ( ref ) ; } } return result ; }
Convert the collected rows into a hierarchy of beans where list references are initalized .