Class ThreadLocalBufferedGeneratorDecorator<T>

java.lang.Object
org.refcodes.generator.ThreadLocalBufferedGeneratorDecorator<T>
Type Parameters:
T - the generic type of the elements being generated.
All Implemented Interfaces:
Iterator<T>, BufferedGenerator<T>, Generator<T>, org.refcodes.mixin.DecorateeAccessor<Iterator<T>>, org.refcodes.mixin.Disposable, org.refcodes.mixin.Suspendable

public class ThreadLocalBufferedGeneratorDecorator<T> extends Object implements BufferedGenerator<T>, org.refcodes.mixin.DecorateeAccessor<Iterator<T>>, org.refcodes.mixin.Disposable
The ThreadLocalBufferedGeneratorDecorator decorates a Generator with read-ahead functionality by buffering generated IDs on a per Thread basis: The resulting Generator is thread safe!.
  • Field Details

  • Constructor Details

  • Method Details

    • hasNext

      public boolean hasNext()
      Tests whether the Generator is capable of generating a Generator.next() item.
      Specified by:
      hasNext in interface Generator<T>
      Specified by:
      hasNext in interface Iterator<T>
      Returns:
      true, if successful
    • next

      public T next()
      Generates a next item.
      Specified by:
      next in interface Generator<T>
      Specified by:
      next in interface Iterator<T>
      Returns:
      The next item generated
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<T>
    • suspend

      public void suspend()
      Specified by:
      suspend in interface org.refcodes.mixin.Suspendable
    • getDecoratee

      public Iterator<T> getDecoratee()
      Specified by:
      getDecoratee in interface org.refcodes.mixin.DecorateeAccessor<T>
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.refcodes.mixin.Disposable