Class LazyMatchingTypeIterator<T>

  • Type Parameters:
    T - Type of iterated element
    All Implemented Interfaces:
    Iterator<T>

    public class LazyMatchingTypeIterator<T>
    extends Object
    implements Iterator<T>
    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 Detail

      • finished

        protected boolean finished
      • nextValue

        protected T nextValue
    • Constructor Detail

      • LazyMatchingTypeIterator

        public LazyMatchingTypeIterator​(Iterator<?> values,
                                        Class<T> type)
    • Method Detail

      • getValues

        public Iterator<?> getValues()
      • getType

        public Class<T> getType()
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface Iterator<T>
      • 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 if null
        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 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.