Class UuidGenerator

java.lang.Object
me.ahoo.cosid.jvm.UuidGenerator
All Implemented Interfaces:
IdGenerator, Statistical, StringIdGenerator

public class UuidGenerator extends Object implements IdGenerator
UUID ID Generator.
  • Field Details

  • Constructor Details

    • UuidGenerator

      public UuidGenerator()
  • Method Details

    • generate

      public long generate()
      Description copied from interface: IdGenerator
      Generate a distributed ID as a long value.

      This method generates a unique numeric identifier that is guaranteed to be unique within the distributed system. The exact algorithm used depends on the implementation (e.g., Snowflake, Segment, CosId).

      Specified by:
      generate in interface IdGenerator
      Returns:
      A unique distributed ID as a long value
    • generateAsString

      @Nonnull public String generateAsString()
      Description copied from interface: IdGenerator
      Generate a distributed ID as a string value.

      This method generates a unique string identifier by first generating a numeric ID via IdGenerator.generate() and then converting it to a string using the configured IdGenerator.idConverter().

      Specified by:
      generateAsString in interface IdGenerator
      Specified by:
      generateAsString in interface StringIdGenerator
      Returns:
      A unique distributed ID as a string value