Class Generator<T>

  • Type Parameters:
    T - type of the object.
    All Implemented Interfaces:
    java.lang.Iterable<T>

    public abstract class Generator<T>
    extends java.lang.Object
    implements java.lang.Iterable<T>
    Generator class that yields instances of T type objects as soon as they are ready.
    • Constructor Summary

      Constructors 
      Constructor Description
      Generator()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Iterator<T> iterator()  
      protected abstract void run()  
      void yield​(T element)
      Makes available the next item.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • Generator

        public Generator()
    • Method Detail

      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>
      • run

        protected abstract void run()
                             throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • yield

        public void yield​(T element)
                   throws java.lang.InterruptedException
        Makes available the next item.
        Parameters:
        element - the next item
        Throws:
        java.lang.InterruptedException - if await fails