Class IncrementingUuidGenerator

java.lang.Object
io.cucumber.core.eventbus.IncrementingUuidGenerator
All Implemented Interfaces:
UuidGenerator, Supplier<UUID>

public class IncrementingUuidGenerator extends Object implements UuidGenerator
Thread-safe and collision-free UUID generator for single JVM. This is a sequence generator and each instance has its own counter. This generator is about 100 times faster than #RandomUuidGenerator. Properties: - thread-safe - collision-free in the same classloader - almost collision-free in different classloaders / JVMs - UUIDs generated using the instances from the same classloader are sortable UUID version 8 (custom) / variant 2 ... | 40 bits | 8 bits | 4 bits | 12 bits | 2 bits | 62 bits | | -------------------| -------------- | ------- | ------------- | ------- | ------- | | LSBs of epoch-time | sessionCounter | version | classloaderId | variant | counter |
  • Constructor Details

    • IncrementingUuidGenerator

      public IncrementingUuidGenerator()
  • Method Details

    • generateId

      public UUID generateId()
      Generate a new UUID. Will throw an exception when out of capacity.
      Specified by:
      generateId in interface UuidGenerator
      Returns:
      a non-null UUID
      Throws:
      CucumberException - when out of capacity