T - Type of element being selectedpublic class LazyMatchingTypeIterable<T>
extends java.lang.Object
implements java.lang.Iterable<T>
Iterable over values that match a
specific type out of all available. The "lazy" denomination
is due to the fact that the next matching value is calculated on-the-fly
every time Iterator.hasNext() is called| Modifier and Type | Field and Description |
|---|---|
private java.lang.Class<T> |
type |
private java.lang.Iterable<?> |
values |
| Constructor and Description |
|---|
LazyMatchingTypeIterable(java.lang.Iterable<?> values,
java.lang.Class<T> type) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Class<T> |
getType() |
java.lang.Iterable<?> |
getValues() |
java.util.Iterator<T> |
iterator() |
static <T> java.lang.Iterable<T> |
lazySelectMatchingTypes(java.lang.Iterable<?> values,
java.lang.Class<T> type) |
java.lang.String |
toString() |
private final java.lang.Iterable<?> values
private final java.lang.Class<T> type
public LazyMatchingTypeIterable(java.lang.Iterable<?> values,
java.lang.Class<T> type)
public java.lang.Iterable<?> getValues()
public java.lang.Class<T> getType()
public java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>public java.lang.String toString()
toString in class java.lang.Objectpublic static <T> java.lang.Iterable<T> lazySelectMatchingTypes(java.lang.Iterable<?> 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.Iterable whose Iterator 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.