Class FilterIterator<ELEMENTTYPE>
- java.lang.Object
-
- com.helger.commons.collection.iterate.FilterIterator<ELEMENTTYPE>
-
- Type Parameters:
ELEMENTTYPE- The type to iterate
- All Implemented Interfaces:
ICommonsIterable<ELEMENTTYPE>,IIterableIterator<ELEMENTTYPE>,Iterable<ELEMENTTYPE>,Iterator<ELEMENTTYPE>
public class FilterIterator<ELEMENTTYPE> extends Object implements IIterableIterator<ELEMENTTYPE>
A simple filter iterator that takes a base iterator and an additional filter and returns only the items that match the filter.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description FilterIterator(IIterableIterator<? extends ELEMENTTYPE> aBaseIter, Predicate<? super ELEMENTTYPE> aFilter)Constructor.FilterIterator(Iterable<? extends ELEMENTTYPE> aBaseCont, Predicate<? super ELEMENTTYPE> aFilter)Constructor.FilterIterator(Iterator<? extends ELEMENTTYPE> aBaseIter, Predicate<? super ELEMENTTYPE> aFilter)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Predicate<? super ELEMENTTYPE>getFilter()booleanhasNext()ELEMENTTYPEnext()voidremove()StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachBreakable, forEachByIndex, forEachThrowing, getCount, getCount
-
Methods inherited from interface com.helger.commons.collection.iterate.IIterableIterator
iterator, withFilter, withMapper
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
FilterIterator
public FilterIterator(@Nonnull IIterableIterator<? extends ELEMENTTYPE> aBaseIter, @Nonnull Predicate<? super ELEMENTTYPE> aFilter)
Constructor.- Parameters:
aBaseIter- The base iterable iterator to use. May not benull.aFilter- The filter to be applied. May not benull.
-
FilterIterator
public FilterIterator(@Nonnull Iterator<? extends ELEMENTTYPE> aBaseIter, @Nonnull Predicate<? super ELEMENTTYPE> aFilter)
Constructor.- Parameters:
aBaseIter- The base iterator to use. May not benull.aFilter- The filter to be applied. May not benull.
-
FilterIterator
public FilterIterator(@Nonnull Iterable<? extends ELEMENTTYPE> aBaseCont, @Nonnull Predicate<? super ELEMENTTYPE> aFilter)
Constructor.- Parameters:
aBaseCont- The collection to iterate. May not benull.aFilter- The filter to be applied. May not benull.
-
-
Method Detail
-
getFilter
@Nonnull public Predicate<? super ELEMENTTYPE> getFilter()
- Returns:
- The filter as specified in the constructor.
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfaceIterator<ELEMENTTYPE>
-
next
@Nullable public ELEMENTTYPE next()
- Specified by:
nextin interfaceIterator<ELEMENTTYPE>
-
remove
public void remove()
- Specified by:
removein interfaceIterator<ELEMENTTYPE>
-
-