Class SingleItemPeekableItemReader<T>

  • All Implemented Interfaces:
    ItemReader<T>, ItemStream, ItemStreamReader<T>, PeekableItemReader<T>

    public class SingleItemPeekableItemReader<T>
    extends java.lang.Object
    implements ItemStreamReader<T>, PeekableItemReader<T>

    A PeekableItemReader that allows the user to peek one item ahead. Repeated calls to peek() will return the same item, and this will be the next item returned from read().

    Intentionally not thread-safe: it wouldn't be possible to honour the peek in multiple threads because only one of the threads that peeked would get that item in the next call to read.

    Author:
    Dave Syer
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidclose()
      If the delegate is an ItemStream, just pass the call on, otherwise reset the peek cache.
      voidopen​(ExecutionContext executionContext)
      If the delegate is an ItemStream, just pass the call on, otherwise reset the peek cache.
      Tpeek()
      Peek at the next item, ensuring that if the delegate is an ItemStream the state is stored for the next call to update(ExecutionContext).
      Tread()
      Get the next item from the delegate (whether or not it has already been peeked at).
      voidsetDelegate​(ItemReader<T> delegate)
      The item reader to use as a delegate.
      voidupdate​(ExecutionContext executionContext)
      If there is a cached peek, then retrieve the execution context state from that point.
      • Methods inherited from class java.lang.Object

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