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>
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
  • Field Details

    • finished

      protected boolean finished
    • nextValue

      protected T nextValue
    • values

      private final Iterator<?> values
    • type

      private final Class<T> type
  • Constructor Details

    • LazyMatchingTypeIterator

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

    • 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>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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.