private static void findLayerOrder ( final Object /* ModuleLayer */ layer , final Set < Object > /* Set<ModuleLayer> */ layerVisited , final Set < Object > /* Set<ModuleLayer> */ parentLayers , final Deque < Object > /* Deque<ModuleLayer> */ layerOrderOut ) { if ( layerVisited . add ( layer ) ) { @ SuppressWarnings ( "unchecked" ) final List < Object > /* List<ModuleLayer> */ parents = ( List < Object > ) ReflectionUtils . invokeMethod ( layer , "parents" , /* throwException = */ true ) ; if ( parents != null ) { parentLayers . addAll ( parents ) ; for ( final Object parent : parents ) { findLayerOrder ( parent , layerVisited , parentLayers , layerOrderOut ) ; } } layerOrderOut . push ( layer ) ; } }
Recursively find the topological sort order of ancestral layers .