T - Type of iterated elementpublic class LazyMatchingTypeIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>
Iterator 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 when hasNext() is called| Modifier and Type | Field and Description |
|---|---|
protected boolean |
finished |
protected T |
nextValue |
private java.lang.Class<T> |
type |
private java.util.Iterator<?> |
values |
| Constructor and Description |
|---|
LazyMatchingTypeIterator(java.util.Iterator<?> values,
java.lang.Class<T> type) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Class<T> |
getType() |
java.util.Iterator<?> |
getValues() |
boolean |
hasNext() |
static <T> java.util.Iterator<T> |
lazySelectMatchingTypes(java.util.Iterator<?> values,
java.lang.Class<T> type) |
T |
next() |
java.lang.String |
toString() |
protected boolean finished
protected T nextValue
private final java.util.Iterator<?> values
private final java.lang.Class<T> type
public LazyMatchingTypeIterator(java.util.Iterator<?> values,
java.lang.Class<T> type)
public java.util.Iterator<?> getValues()
public java.lang.Class<T> getType()
public boolean hasNext()
hasNext in interface java.util.Iterator<T>public java.lang.String toString()
toString in class java.lang.Objectpublic static <T> java.util.Iterator<T> lazySelectMatchingTypes(java.util.Iterator<?> values,
java.lang.Class<T> type)
T - Type if iterated elementvalues - The source values - ignored if nulltype - The (never @code null) type of values to select - any value
whose type is assignable to this type will be selected by the iterator.Iterator whose next() 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 when Iterator.hasNext() is called.