Class LazyMatchingTypeIterator<T>
- java.lang.Object
-
- org.apache.sshd.common.util.helper.LazyMatchingTypeIterator<T>
-
- Type Parameters:
T
- Type of iterated element
- All Implemented Interfaces:
Iterator<T>
public class LazyMatchingTypeIterator<T> extends Object implements Iterator<T>
AnIterator
that selects only objects of a certain type from the underlying available ones. The "lazy" denomination is due to the fact that selection occurs only whenhasNext()
is called- Author:
- Apache MINA SSHD Project
-
-
Constructor Summary
Constructors Constructor Description LazyMatchingTypeIterator(Iterator<?> values, Class<T> type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<T>
getType()
Iterator<?>
getValues()
boolean
hasNext()
static <T> Iterator<T>
lazySelectMatchingTypes(Iterator<?> values, Class<T> type)
T
next()
String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
finished
protected boolean finished
-
nextValue
protected T nextValue
-
-
Method Detail
-
getValues
public Iterator<?> getValues()
-
lazySelectMatchingTypes
public static <T> Iterator<T> lazySelectMatchingTypes(Iterator<?> values, Class<T> type)
- Type Parameters:
T
- Type if iterated element- Parameters:
values
- The source values - ignored ifnull
type
- The (never @code null) type of values to select - any value whose type is assignable to this type will be selected by the iterator.- Returns:
- An
Iterator
whosenext()
call selects only values matching the specific type. Note: the matching values are not pre-calculated (hence the "lazy" denomination) - i.e., the match is performed only whenIterator.hasNext()
is called.
-
-