Interface NameGenerator

  • All Implemented Interfaces:
    kotlin.collections.Iterator

    
    public interface NameGenerator
     implements Iterator<Name>
                        

    Generates an either endless or finite amount of names.

    A name generator is an Iterator which allows for easy iteration, i.e. via

    for(name in names) {
     // ...
    }

    Be sure to check for isAutoResetting before iterating! An auto-resetting name generator will create an endless loop.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Name next() Generates the next Name, if possible.
      abstract Boolean hasNext()
      abstract Unit reset() Resets this name generator to its initial state.
      abstract Boolean isAutoResetting() If this flag is true, the generator automatically resets itself when all names have been generated.
      abstract Integer getNameCount() The total number of names this generator can generate before needing to reset.
      • Methods inherited from class kotlin.collections.Iterator

        forEachRemaining
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • next

         abstract Name next()

        Generates the next Name, if possible.

      • hasNext

         abstract Boolean hasNext()
        Returns:

        true if this generator is able to generate another Name. This means, that it is safe to call next.

      • reset

         abstract Unit reset()

        Resets this name generator to its initial state. Calling next afterward may return the same order of Names as the previous times. But the contract does not require such behavior.

      • isAutoResetting

         abstract Boolean isAutoResetting()

        If this flag is true, the generator automatically resets itself when all names have been generated. This means it provides an endless stream of values. reset does not need to be called manually.

        Be careful when iterating over an auto-resetting NameGenerator! You may end up in an endless loop.