Top Description Fields Constructors Methods
org.apache.sshd.common.util.helper

public Class LazyMatchingTypeIterator<T>

extends Object
implements Iterator<T>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Type Parameters
<T>
Type of iterated element
Imports
java.util.Collections, .Iterator, .NoSuchElementException, .Objects, org.apache.sshd.common.util.GenericUtils

An 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
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
protected boolean
protected T
private final Class<T>
private final Iterator<?>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Class<T>
public Iterator<?>
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public static <
Type if iterated element
T
>
Iterator<T>

Returns:

An 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.

lazySelectMatchingTypes
(Iterator<?>
The source values - ignored if null
values
,
Class<T>
The (never @code null) type of values to select - any value whose type is assignable to this type will be selected by the iterator.
type
)

public T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

finishedback to summary
protected boolean finished
nextValueback to summary
protected T nextValue
typeback to summary
private final Class<T> type
valuesback to summary
private final Iterator<?> values

Constructor Detail

LazyMatchingTypeIteratorback to summary
public LazyMatchingTypeIterator(Iterator<?> values, Class<T> type)

Method Detail

getTypeback to summary
public Class<T> getType()
getValuesback to summary
public Iterator<?> getValues()
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
lazySelectMatchingTypesback to summary
public static <T> Iterator<T> lazySelectMatchingTypes(Iterator<?> values, Class<T> type)
Parameters
<T>
Type if iterated element
values:Iterator<?>

The source values - ignored if null

type:Class<T>

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:Iterator<T>

An 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.

nextback to summary
public T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override