private Set<Bean> flattenReferences(Bean bean) {
        Set<Bean> beans = new HashSet<>();
        for (String referenceName : bean.getReferenceNames()) {
            List<BeanId> ids = bean.getReference(referenceName);
            for (BeanId id : ids) {
                if (id.getBean() == null) {
                    continue;
                }
                beans.addAll(flattenReferences(id.getBean()));
            }
        }
        beans.add(bean);
        return beans;
    }
private Set < Bean > flattenReferences ( Bean bean ) { Set < Bean > beans = new HashSet < > ( ) ; for ( String referenceName : bean . getReferenceNames ( ) ) { List < BeanId > ids = bean . getReference ( referenceName ) ; for ( BeanId id : ids ) { if ( id . getBean ( ) == null ) { continue ; } beans . addAll ( flattenReferences ( id . getBean ( ) ) ) ; } } beans . add ( bean ) ; return beans ; }
Bean may, but not necessarily, have deep hierarchies of references
to other beans. Since a cache store beans per schema we must
dig out this hierarchy and flatten it out,