Package me.ahoo.cosid.jvm
Class UuidGenerator
java.lang.Object
me.ahoo.cosid.jvm.UuidGenerator
- All Implemented Interfaces:
IdGenerator
,Statistical
,StringIdGenerator
UUID ID Generator.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
generate()
Generate a distributed ID as a long value.Generate a distributed ID as a string value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface me.ahoo.cosid.IdGenerator
idConverter, stat
-
Field Details
-
INSTANCE
-
-
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 interfaceIdGenerator
- Returns:
- A unique distributed ID as a long value
-
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 configuredIdGenerator.idConverter()
.- Specified by:
generateAsString
in interfaceIdGenerator
- Specified by:
generateAsString
in interfaceStringIdGenerator
- Returns:
- A unique distributed ID as a string value
-