Class LazyMatchingTypeIterable<T>

java.lang.Object
org.apache.sshd.common.util.helper.LazyMatchingTypeIterable<T>
Type Parameters:
T - Type of element being selected
All Implemented Interfaces:
Iterable<T>

public class LazyMatchingTypeIterable<T> extends Object implements Iterable<T>
Provides a selective 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
  • Field Details

    • values

      private final Iterable<?> values
    • type

      private final Class<T> type
  • Constructor Details

    • LazyMatchingTypeIterable

      public LazyMatchingTypeIterable(Iterable<?> values, Class<T> type)
  • Method Details

    • getValues

      public Iterable<?> getValues()
    • getType

      public Class<T> getType()
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • lazySelectMatchingTypes

      public static <T> Iterable<T> lazySelectMatchingTypes(Iterable<?> 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:
      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.