@Test public void testDeriveChildTraverser_Unchanged() { DependencyTraverser other1 = new DummyDependencyTraverser( true ); DependencyTraverser other2 = new DummyDependencyTraverser( false ); DependencyTraverser traverser = new AndDependencyTraverser( other1, other2 ); assertSame( traverser, traverser.deriveChildTraverser( null ) ); }
public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) { int seen = 0; Set<DependencyTraverser> childTraversers = null; for ( DependencyTraverser traverser : traversers ) { DependencyTraverser childTraverser = traverser.deriveChildTraverser( context ); if ( childTraversers != null ) { if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else if ( traverser != childTraverser ) { childTraversers = new LinkedHashSet<DependencyTraverser>(); if ( seen > 0 ) { for ( DependencyTraverser s : traversers ) { if ( childTraversers.size() >= seen ) { break; } childTraversers.add( s ); } } if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else { seen++; } } if ( childTraversers == null ) { return this; } if ( childTraversers.size() <= 1 ) { if ( childTraversers.isEmpty() ) { return null; } return childTraversers.iterator().next(); } return new AndDependencyTraverser( childTraversers ); }
AndDependencyTraverser implements DependencyTraverser { public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) { int seen = 0; Set<DependencyTraverser> childTraversers = null; for ( DependencyTraverser traverser : traversers ) { DependencyTraverser childTraverser = traverser.deriveChildTraverser( context ); if ( childTraversers != null ) { if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else if ( traverser != childTraverser ) { childTraversers = new LinkedHashSet<DependencyTraverser>(); if ( seen > 0 ) { for ( DependencyTraverser s : traversers ) { if ( childTraversers.size() >= seen ) { break; } childTraversers.add( s ); } } if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else { seen++; } } if ( childTraversers == null ) { return this; } if ( childTraversers.size() <= 1 ) { if ( childTraversers.isEmpty() ) { return null; } return childTraversers.iterator().next(); } return new AndDependencyTraverser( childTraversers ); } }
AndDependencyTraverser implements DependencyTraverser { public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) { int seen = 0; Set<DependencyTraverser> childTraversers = null; for ( DependencyTraverser traverser : traversers ) { DependencyTraverser childTraverser = traverser.deriveChildTraverser( context ); if ( childTraversers != null ) { if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else if ( traverser != childTraverser ) { childTraversers = new LinkedHashSet<DependencyTraverser>(); if ( seen > 0 ) { for ( DependencyTraverser s : traversers ) { if ( childTraversers.size() >= seen ) { break; } childTraversers.add( s ); } } if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else { seen++; } } if ( childTraversers == null ) { return this; } if ( childTraversers.size() <= 1 ) { if ( childTraversers.isEmpty() ) { return null; } return childTraversers.iterator().next(); } return new AndDependencyTraverser( childTraversers ); } AndDependencyTraverser( DependencyTraverser... traversers );  AndDependencyTraverser( Collection<? extends DependencyTraverser> traversers ); private  AndDependencyTraverser( Set<DependencyTraverser> traversers ); }
AndDependencyTraverser implements DependencyTraverser { public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) { int seen = 0; Set<DependencyTraverser> childTraversers = null; for ( DependencyTraverser traverser : traversers ) { DependencyTraverser childTraverser = traverser.deriveChildTraverser( context ); if ( childTraversers != null ) { if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else if ( traverser != childTraverser ) { childTraversers = new LinkedHashSet<DependencyTraverser>(); if ( seen > 0 ) { for ( DependencyTraverser s : traversers ) { if ( childTraversers.size() >= seen ) { break; } childTraversers.add( s ); } } if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else { seen++; } } if ( childTraversers == null ) { return this; } if ( childTraversers.size() <= 1 ) { if ( childTraversers.isEmpty() ) { return null; } return childTraversers.iterator().next(); } return new AndDependencyTraverser( childTraversers ); } AndDependencyTraverser( DependencyTraverser... traversers );  AndDependencyTraverser( Collection<? extends DependencyTraverser> traversers ); private  AndDependencyTraverser( Set<DependencyTraverser> traversers ); static DependencyTraverser newInstance( DependencyTraverser traverser1, DependencyTraverser traverser2 ); boolean traverseDependency( Dependency dependency ); DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ); @Override boolean equals( Object obj ); @Override int hashCode(); }
AndDependencyTraverser implements DependencyTraverser { public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) { int seen = 0; Set<DependencyTraverser> childTraversers = null; for ( DependencyTraverser traverser : traversers ) { DependencyTraverser childTraverser = traverser.deriveChildTraverser( context ); if ( childTraversers != null ) { if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else if ( traverser != childTraverser ) { childTraversers = new LinkedHashSet<DependencyTraverser>(); if ( seen > 0 ) { for ( DependencyTraverser s : traversers ) { if ( childTraversers.size() >= seen ) { break; } childTraversers.add( s ); } } if ( childTraverser != null ) { childTraversers.add( childTraverser ); } } else { seen++; } } if ( childTraversers == null ) { return this; } if ( childTraversers.size() <= 1 ) { if ( childTraversers.isEmpty() ) { return null; } return childTraversers.iterator().next(); } return new AndDependencyTraverser( childTraversers ); } AndDependencyTraverser( DependencyTraverser... traversers );  AndDependencyTraverser( Collection<? extends DependencyTraverser> traversers ); private  AndDependencyTraverser( Set<DependencyTraverser> traversers ); static DependencyTraverser newInstance( DependencyTraverser traverser1, DependencyTraverser traverser2 ); boolean traverseDependency( Dependency dependency ); DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ); @Override boolean equals( Object obj ); @Override int hashCode();  }