Class FunctionIterator<T,​V>

java.lang.Object
org.springframework.integration.util.FunctionIterator<T,​V>
Type Parameters:
T - inbound iterator element type.
V - outbound element type.
All Implemented Interfaces:
java.lang.AutoCloseable, java.util.Iterator<V>, CloseableIterator<V>

public class FunctionIterator<T,​V>
extends java.lang.Object
implements CloseableIterator<V>
An Iterator implementation to convert each item from the target iterator to a new object applying the function on next().
Since:
4.1
  • Constructor Summary

    Constructors 
    Constructor Description
    FunctionIterator​(java.lang.AutoCloseable closeable, java.lang.Iterable<T> iterable, java.util.function.Function<? super T,​? extends V> function)
    Construct an instance with the provided root object, iterable and function.
    FunctionIterator​(java.lang.AutoCloseable closeable, java.util.Iterator<T> newIterator, java.util.function.Function<? super T,​? extends V> function)
    Construct an instance with the provided root object, iterator and function.
    FunctionIterator​(java.lang.Iterable<T> iterable, java.util.function.Function<? super T,​? extends V> function)
    Construct an instance with the provided iterable and function.
    FunctionIterator​(java.util.Iterator<T> newIterator, java.util.function.Function<? super T,​? extends V> function)
    Construct an instance with the provided iterator and function.
  • Method Summary

    Modifier and Type Method Description
    void close()  
    boolean hasNext()  
    V next()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining, remove
  • Constructor Details

    • FunctionIterator

      public FunctionIterator​(java.lang.Iterable<T> iterable, java.util.function.Function<? super T,​? extends V> function)
      Construct an instance with the provided iterable and function.
      Parameters:
      iterable - the iterable.
      function - the function.
    • FunctionIterator

      public FunctionIterator​(@Nullable java.lang.AutoCloseable closeable, java.lang.Iterable<T> iterable, java.util.function.Function<? super T,​? extends V> function)
      Construct an instance with the provided root object, iterable and function.
      Parameters:
      closeable - an AutoCloseable to close when iteration is complete.
      iterable - the iterable.
      function - the function.
      Since:
      5.0.7
    • FunctionIterator

      public FunctionIterator​(java.util.Iterator<T> newIterator, java.util.function.Function<? super T,​? extends V> function)
      Construct an instance with the provided iterator and function.
      Parameters:
      newIterator - the iterator.
      function - the function.
    • FunctionIterator

      public FunctionIterator​(@Nullable java.lang.AutoCloseable closeable, java.util.Iterator<T> newIterator, java.util.function.Function<? super T,​? extends V> function)
      Construct an instance with the provided root object, iterator and function.
      Parameters:
      closeable - an AutoCloseable to close when iteration is complete.
      newIterator - the iterator.
      function - the function.
      Since:
      5.0.7
  • Method Details

    • hasNext

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

      public V next()
      Specified by:
      next in interface java.util.Iterator<T>
    • close

      public void close()
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface CloseableIterator<T>