@Override public Iterator<T> iterator() { return new FilteringIterator<>( source.iterator(), predicate ); }
@Test void testNoDuplicatesFilteringIterator() { List<Integer> ints = asList( 1, 2, 2, 40, 100, 40, 101, 2, 3 ); Iterator<Integer> iterator = FilteringIterator.noDuplicates( ints.iterator() ); assertEquals( (Integer) 1, iterator.next() ); assertEquals( (Integer) 2, iterator.next() ); assertEquals( (Integer) 40, iterator.next() ); assertEquals( (Integer) 100, iterator.next() ); assertEquals( (Integer) 101, iterator.next() ); assertEquals( (Integer) 3, iterator.next() ); }
@Override protected Relationship fetchNextOrNull() { return handBreak.get() ? null : super.fetchNextOrNull(); } };
public static <T> Iterator<T> notNull( Iterator<T> source ) { return new FilteringIterator<>( source, Predicates.notNull() ); }
public static <T> Iterator<T> noDuplicates( Iterator<T> source ) { return new FilteringIterator<>( source, Predicates.noDuplicates() ); } }
private Iterable<CommonAbstractStore> instantiatedRecordStores() { Iterator<StoreType> storeTypes = new FilteringIterator<>( iterator( STORE_TYPES ), INSTANTIATED_RECORD_STORES ); return loop( new IteratorWrapper<CommonAbstractStore,StoreType>( storeTypes ) { @Override protected CommonAbstractStore underlyingObjectToObject( StoreType type ) { return (CommonAbstractStore) stores[type.ordinal()]; } } ); }
@Override public Iterator<PropertyRecord> rawPropertyChain( long firstId ) { return new FilteringIterator<>( super.rawPropertyChain( firstId ), item -> shouldCheck( item.getId() /*for some reason we don't care about the id*/, MultiPassStore.PROPERTIES ) ); }
@Override ResourceIterator<Relationship> doExpand( Path path, BranchState state ) { final Node node = path.endNode(); ResourceIterator<Relationship> resourceIterator = asResourceIterator( node.getRelationships().iterator() ); return newResourceIterator( new FilteringIterator<>( resourceIterator, rel -> { Exclusion exclude = exclusion.get( rel.getType().name() ); exclude = (exclude == null) ? defaultExclusion : exclude; return exclude.accept( node, rel ); } ), resourceIterator ); }
@Override ResourceIterator<Relationship> doExpand( final Path path, BranchState state ) { ResourceIterator<Relationship> resourceIterator = expander.doExpand( path, state ); return newResourceIterator( new FilteringIterator<>( resourceIterator, item -> { Path extendedPath = ExtendedPath.extend( path, item ); for ( Filter filter : filters ) { if ( filter.exclude( extendedPath ) ) { return false; } } return true; } ), resourceIterator ); }
List<StorageCommand> createCommands = Iterators.asList( new FilteringIterator<>( commandsInFirstEntry.iterator(), item -> item instanceof IndexDefineCommand
@Override public Iterator<T> iterator() { return new FilteringIterator<>( source.iterator(), predicate ); }
public static <T> Iterator<T> noDuplicates( Iterator<T> source ) { return new FilteringIterator<>( source, Predicates.noDuplicates() ); } }
public static <T> Iterator<T> notNull( Iterator<T> source ) { return new FilteringIterator<>( source, Predicates.notNull() ); }
protected Iterator<Relationship> getAllRelationships() { return new FilteringIterator<Relationship>( node.getRelationships( type, getDirection() ).iterator(), new Predicate<Relationship>() { public boolean accept(Relationship item) { return shouldIncludeRelationship( item ); } } ); }
private Iterable<CommonAbstractStore> instantiatedRecordStores() { Iterator<StoreType> storeTypes = new FilteringIterator<>( iterator( STORE_TYPES ), INSTANTIATED_RECORD_STORES ); return loop( new IteratorWrapper<CommonAbstractStore,StoreType>( storeTypes ) { @Override protected CommonAbstractStore underlyingObjectToObject( StoreType type ) { return (CommonAbstractStore) stores[type.ordinal()]; } } ); }
@Override ResourceIterator<Relationship> doExpand( Path path, BranchState state ) { final Node node = path.endNode(); ResourceIterator<Relationship> resourceIterator = asResourceIterator( node.getRelationships().iterator() ); return newResourceIterator( new FilteringIterator<>( resourceIterator, rel -> { Exclusion exclude = exclusion.get( rel.getType().name() ); exclude = (exclude == null) ? defaultExclusion : exclude; return exclude.accept( node, rel ); } ), resourceIterator ); }
@Override ResourceIterator<Relationship> doExpand( final Path path, BranchState state ) { ResourceIterator<Relationship> resourceIterator = expander.doExpand( path, state ); return newResourceIterator( new FilteringIterator<>( resourceIterator, item -> { Path extendedPath = ExtendedPath.extend( path, item ); for ( Filter filter : filters ) { if ( filter.exclude( extendedPath ) ) { return false; } } return true; } ), resourceIterator ); }