Package de.gleex.kng.api
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.
-
-
Method Summary
Modifier and Type Method Description abstract Namenext()Generates the next Name, if possible. abstract BooleanhasNext()abstract Unitreset()Resets this name generator to its initial state. abstract BooleanisAutoResetting()If this flag is true, the generator automatically resets itself when all names have been generated.abstract IntegergetNameCount()The total number of names this generator can generate before needing to reset. -
-
Method Detail
-
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.
-
getNameCount
abstract Integer getNameCount()
-
-
-
-