@Test public void testDeriveChildSelector_Unchanged() { DependencySelector other1 = new DummyDependencySelector( true ); DependencySelector other2 = new DummyDependencySelector( false ); DependencySelector selector = new AndDependencySelector( other1, other2 ); assertSame( selector, selector.deriveChildSelector( null ) ); }
public DependencySelector deriveChildSelector( DependencyCollectionContext context ) { int seen = 0; Set<DependencySelector> childSelectors = null; for ( DependencySelector selector : selectors ) { DependencySelector childSelector = selector.deriveChildSelector( context ); if ( childSelectors != null ) { if ( childSelector != null ) { childSelectors.add( childSelector ); } } else if ( selector != childSelector ) { childSelectors = new LinkedHashSet<DependencySelector>(); if ( seen > 0 ) { for ( DependencySelector s : selectors ) { if ( childSelectors.size() >= seen ) { break; } childSelectors.add( s ); } } if ( childSelector != null ) { childSelectors.add( childSelector ); } } else { seen++; } } if ( childSelectors == null ) { return this; } if ( childSelectors.size() <= 1 ) { if ( childSelectors.isEmpty() ) { return null; } return childSelectors.iterator().next(); } return new AndDependencySelector( childSelectors ); }
AndDependencySelector implements DependencySelector { public DependencySelector deriveChildSelector( DependencyCollectionContext context ) { int seen = 0; Set<DependencySelector> childSelectors = null; for ( DependencySelector selector : selectors ) { DependencySelector childSelector = selector.deriveChildSelector( context ); if ( childSelectors != null ) { if ( childSelector != null ) { childSelectors.add( childSelector ); } } else if ( selector != childSelector ) { childSelectors = new LinkedHashSet<DependencySelector>(); if ( seen > 0 ) { for ( DependencySelector s : selectors ) { if ( childSelectors.size() >= seen ) { break; } childSelectors.add( s ); } } if ( childSelector != null ) { childSelectors.add( childSelector ); } } else { seen++; } } if ( childSelectors == null ) { return this; } if ( childSelectors.size() <= 1 ) { if ( childSelectors.isEmpty() ) { return null; } return childSelectors.iterator().next(); } return new AndDependencySelector( childSelectors ); } }
AndDependencySelector implements DependencySelector { public DependencySelector deriveChildSelector( DependencyCollectionContext context ) { int seen = 0; Set<DependencySelector> childSelectors = null; for ( DependencySelector selector : selectors ) { DependencySelector childSelector = selector.deriveChildSelector( context ); if ( childSelectors != null ) { if ( childSelector != null ) { childSelectors.add( childSelector ); } } else if ( selector != childSelector ) { childSelectors = new LinkedHashSet<DependencySelector>(); if ( seen > 0 ) { for ( DependencySelector s : selectors ) { if ( childSelectors.size() >= seen ) { break; } childSelectors.add( s ); } } if ( childSelector != null ) { childSelectors.add( childSelector ); } } else { seen++; } } if ( childSelectors == null ) { return this; } if ( childSelectors.size() <= 1 ) { if ( childSelectors.isEmpty() ) { return null; } return childSelectors.iterator().next(); } return new AndDependencySelector( childSelectors ); } AndDependencySelector( DependencySelector... selectors );  AndDependencySelector( Collection<? extends DependencySelector> selectors ); private  AndDependencySelector( Set<DependencySelector> selectors ); }
AndDependencySelector implements DependencySelector { public DependencySelector deriveChildSelector( DependencyCollectionContext context ) { int seen = 0; Set<DependencySelector> childSelectors = null; for ( DependencySelector selector : selectors ) { DependencySelector childSelector = selector.deriveChildSelector( context ); if ( childSelectors != null ) { if ( childSelector != null ) { childSelectors.add( childSelector ); } } else if ( selector != childSelector ) { childSelectors = new LinkedHashSet<DependencySelector>(); if ( seen > 0 ) { for ( DependencySelector s : selectors ) { if ( childSelectors.size() >= seen ) { break; } childSelectors.add( s ); } } if ( childSelector != null ) { childSelectors.add( childSelector ); } } else { seen++; } } if ( childSelectors == null ) { return this; } if ( childSelectors.size() <= 1 ) { if ( childSelectors.isEmpty() ) { return null; } return childSelectors.iterator().next(); } return new AndDependencySelector( childSelectors ); } AndDependencySelector( DependencySelector... selectors );  AndDependencySelector( Collection<? extends DependencySelector> selectors ); private  AndDependencySelector( Set<DependencySelector> selectors ); static DependencySelector newInstance( DependencySelector selector1, DependencySelector selector2 ); boolean selectDependency( Dependency dependency ); DependencySelector deriveChildSelector( DependencyCollectionContext context ); @Override boolean equals( Object obj ); @Override int hashCode(); }
AndDependencySelector implements DependencySelector { public DependencySelector deriveChildSelector( DependencyCollectionContext context ) { int seen = 0; Set<DependencySelector> childSelectors = null; for ( DependencySelector selector : selectors ) { DependencySelector childSelector = selector.deriveChildSelector( context ); if ( childSelectors != null ) { if ( childSelector != null ) { childSelectors.add( childSelector ); } } else if ( selector != childSelector ) { childSelectors = new LinkedHashSet<DependencySelector>(); if ( seen > 0 ) { for ( DependencySelector s : selectors ) { if ( childSelectors.size() >= seen ) { break; } childSelectors.add( s ); } } if ( childSelector != null ) { childSelectors.add( childSelector ); } } else { seen++; } } if ( childSelectors == null ) { return this; } if ( childSelectors.size() <= 1 ) { if ( childSelectors.isEmpty() ) { return null; } return childSelectors.iterator().next(); } return new AndDependencySelector( childSelectors ); } AndDependencySelector( DependencySelector... selectors );  AndDependencySelector( Collection<? extends DependencySelector> selectors ); private  AndDependencySelector( Set<DependencySelector> selectors ); static DependencySelector newInstance( DependencySelector selector1, DependencySelector selector2 ); boolean selectDependency( Dependency dependency ); DependencySelector deriveChildSelector( DependencyCollectionContext context ); @Override boolean equals( Object obj ); @Override int hashCode();  }