Package com.fasterxml.uuid.impl
Class TimeBasedGenerator
java.lang.Object
com.fasterxml.uuid.UUIDGenerator
com.fasterxml.uuid.NoArgGenerator
com.fasterxml.uuid.impl.TimeBasedGenerator
Implementation of UUID generator that uses time/location based generation
method (version 1).
As all JUG provided implementations, this generator is fully thread-safe.
Additionally, it can also be made externally synchronized with other
instances (even ones running on other JVMs); to do this,
use FileBasedTimestampSynchronizer
(or equivalent).
- Since:
- 3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EthernetAddress
protected final UUIDTimer
Object used for synchronizing access to timestamps, to guarantee that timestamps produced by this generator are unique and monotonically increasings.protected final long
Base values for the second long (last 8 bytes) of UUID to construct -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconstruct
(long rawTimestamp) Method that will construct actualUUID
instance for given timestamp: called bygenerate()
but may alternatively be called directly to construct an instance with known timestamp.generate()
Method for generating aUUID
.getType()
Accessor for determining type of UUIDs (version) that this generator instance will produce.Methods inherited from class com.fasterxml.uuid.UUIDGenerator
_toInt, _toLong, _toShort
-
Field Details
-
_ethernetAddress
-
_timer
Object used for synchronizing access to timestamps, to guarantee that timestamps produced by this generator are unique and monotonically increasings. Some implementations offer even stronger guarantees, for example that same guarantee holds between instances running on different JVMs (or with native code). -
_uuidL2
protected final long _uuidL2Base values for the second long (last 8 bytes) of UUID to construct
-
-
Constructor Details
-
TimeBasedGenerator
- Parameters:
ethAddr
- Hardware address (802.1) to use for generating spatially unique part of UUID. If system has more than one NIC,
-
-
Method Details
-
getType
Description copied from class:UUIDGenerator
Accessor for determining type of UUIDs (version) that this generator instance will produce.- Specified by:
getType
in classUUIDGenerator
-
getEthernetAddress
-
generate
Description copied from class:NoArgGenerator
Method for generating aUUID
.- Specified by:
generate
in classNoArgGenerator
- Returns:
- Newly generated
UUID
-
construct
Method that will construct actualUUID
instance for given timestamp: called bygenerate()
but may alternatively be called directly to construct an instance with known timestamp. NOTE: calling this method directly does NOT guarantee uniqueness of resultingUUID
(caller has to guarantee uniqueness)- Parameters:
rawTimestamp
- Timestamp usually obtained fromUUIDTimer.getTimestamp()
, used for constructing UUID instance- Returns:
- unix Time-based UUID constructed for given timestamp
- Since:
- 4.3
-