@Test public void testFindAllExtendingComponents_cycle() { Component c1 = new Component( "c1" ); Component c2 = new Component( "c2" ); Component c3 = new Component( "c3" ); c3.extendComponent( c2 ); c2.extendComponent( c1 ); Collection<Component> extending = ComponentHelpers.findAllExtendingComponents( c3 ); Assert.assertEquals( 0, extending.size()); extending = ComponentHelpers.findAllExtendingComponents( c2 ); Assert.assertEquals( 1, extending.size()); Assert.assertTrue( extending.contains( c3 )); extending = ComponentHelpers.findAllExtendingComponents( c1 ); Assert.assertEquals( 2, extending.size()); Assert.assertTrue( extending.contains( c2 )); Assert.assertTrue( extending.contains( c3 )); c1.extendComponent( c3 ); Assert.assertEquals( 2, ComponentHelpers.findAllExtendingComponents( c1 ).size()); Assert.assertEquals( 2, ComponentHelpers.findAllExtendingComponents( c2 ).size()); Assert.assertEquals( 2, ComponentHelpers.findAllExtendingComponents( c3 ).size()); }
public static Collection<Component> findAllExtendingComponents( Component component ) { Collection<Component> result = new HashSet<> (); Set<Component> toProcess = new HashSet<>( component.getExtendingComponents()); while( ! toProcess.isEmpty()) { Component c = toProcess.iterator().next(); result.add( c ); toProcess.addAll( c.getExtendingComponents()); toProcess.removeAll( result ); } result.remove( component ); return result; }
ComponentHelpers { public static Collection<Component> findAllExtendingComponents( Component component ) { Collection<Component> result = new HashSet<> (); Set<Component> toProcess = new HashSet<>( component.getExtendingComponents()); while( ! toProcess.isEmpty()) { Component c = toProcess.iterator().next(); result.add( c ); toProcess.addAll( c.getExtendingComponents()); toProcess.removeAll( result ); } result.remove( component ); return result; } }
ComponentHelpers { public static Collection<Component> findAllExtendingComponents( Component component ) { Collection<Component> result = new HashSet<> (); Set<Component> toProcess = new HashSet<>( component.getExtendingComponents()); while( ! toProcess.isEmpty()) { Component c = toProcess.iterator().next(); result.add( c ); toProcess.addAll( c.getExtendingComponents()); toProcess.removeAll( result ); } result.remove( component ); return result; } private  ComponentHelpers(); }
ComponentHelpers { public static Collection<Component> findAllExtendingComponents( Component component ) { Collection<Component> result = new HashSet<> (); Set<Component> toProcess = new HashSet<>( component.getExtendingComponents()); while( ! toProcess.isEmpty()) { Component c = toProcess.iterator().next(); result.add( c ); toProcess.addAll( c.getExtendingComponents()); toProcess.removeAll( result ); } result.remove( component ); return result; } private  ComponentHelpers(); static Component findComponent( Graphs graphs, String name ); static Component findComponent( AbstractApplication app, String name ); static Component findComponentFrom( Component component, String componentName ); static List<String> extractNames( Collection<? extends AbstractType> types ); static boolean isTarget( Component component ); static Collection<Component> findAllChildren( Component component ); static Collection<Component> findAllAncestors( Component component ); static String findComponentInstaller( Component component ); static Map<String,String> findAllExportedVariables( Component component ); static Map<String,String> findAllExportedVariables( AbstractType type ); static Map<String,String> findAllExportedVariables( Graphs graphs ); static Map<String,String> findAllExportedVariables( Facet facet ); static Map<String,ImportedVariable> findAllImportedVariables( Component component ); static Collection<Facet> findAllFacets( Component component ); static List<Component> findAllExtendedComponents( Component component ); static Collection<Facet> findAllExtendedFacets( Facet facet ); static Collection<Facet> findAllExtendingFacets( Facet facet ); static Collection<Component> findAllExtendingComponents( Component component ); static List<Component> findAllComponents( Graphs graphs ); static List<Component> findAllComponents( AbstractApplication app ); static String searchForLoop( Component component ); static String searchForInheritanceCycle( Facet facet ); static String searchForInheritanceCycle( Component component ); static Map<String,Boolean> findComponentDependenciesFor( Component component ); static Map<Component,Boolean> findComponentDependenciesFor( Component component, ApplicationTemplate app ); static Map<Component,Boolean> findComponentsThatDependOn( Component component, ApplicationTemplate app ); }
ComponentHelpers { public static Collection<Component> findAllExtendingComponents( Component component ) { Collection<Component> result = new HashSet<> (); Set<Component> toProcess = new HashSet<>( component.getExtendingComponents()); while( ! toProcess.isEmpty()) { Component c = toProcess.iterator().next(); result.add( c ); toProcess.addAll( c.getExtendingComponents()); toProcess.removeAll( result ); } result.remove( component ); return result; } private  ComponentHelpers(); static Component findComponent( Graphs graphs, String name ); static Component findComponent( AbstractApplication app, String name ); static Component findComponentFrom( Component component, String componentName ); static List<String> extractNames( Collection<? extends AbstractType> types ); static boolean isTarget( Component component ); static Collection<Component> findAllChildren( Component component ); static Collection<Component> findAllAncestors( Component component ); static String findComponentInstaller( Component component ); static Map<String,String> findAllExportedVariables( Component component ); static Map<String,String> findAllExportedVariables( AbstractType type ); static Map<String,String> findAllExportedVariables( Graphs graphs ); static Map<String,String> findAllExportedVariables( Facet facet ); static Map<String,ImportedVariable> findAllImportedVariables( Component component ); static Collection<Facet> findAllFacets( Component component ); static List<Component> findAllExtendedComponents( Component component ); static Collection<Facet> findAllExtendedFacets( Facet facet ); static Collection<Facet> findAllExtendingFacets( Facet facet ); static Collection<Component> findAllExtendingComponents( Component component ); static List<Component> findAllComponents( Graphs graphs ); static List<Component> findAllComponents( AbstractApplication app ); static String searchForLoop( Component component ); static String searchForInheritanceCycle( Facet facet ); static String searchForInheritanceCycle( Component component ); static Map<String,Boolean> findComponentDependenciesFor( Component component ); static Map<Component,Boolean> findComponentDependenciesFor( Component component, ApplicationTemplate app ); static Map<Component,Boolean> findComponentsThatDependOn( Component component, ApplicationTemplate app );  }