Package com.fasterxml.uuid.impl
Class TimeBasedReorderedGenerator
java.lang.Object
com.fasterxml.uuid.UUIDGenerator
com.fasterxml.uuid.NoArgGenerator
com.fasterxml.uuid.impl.TimeBasedReorderedGenerator
Implementation of UUID generator that uses time/location based generation
method field compatible with UUIDv1, reorderd for improved DB locality.
This is usually referred to as "Version 6".
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:
- 4.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EthernetAddressprotected final UUIDTimerObject used for synchronizing access to timestamps, to guarantee that timestamps produced by this generator are unique and monotonically increasings.protected final longBase values for the second long (last 8 bytes) of UUID to constructstatic intstatic intstatic int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconstruct(long rawTimestamp) Method that will construct actualUUIDinstance 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
-
BYTE_OFFSET_TIME_HIGH
public static int BYTE_OFFSET_TIME_HIGH -
BYTE_OFFSET_TIME_MID
public static int BYTE_OFFSET_TIME_MID -
BYTE_OFFSET_TIME_LOW
public static int BYTE_OFFSET_TIME_LOW -
_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
-
TimeBasedReorderedGenerator
- 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:UUIDGeneratorAccessor for determining type of UUIDs (version) that this generator instance will produce.- Specified by:
getTypein classUUIDGenerator
-
getEthernetAddress
-
generate
Description copied from class:NoArgGeneratorMethod for generating aUUID.- Specified by:
generatein classNoArgGenerator- Returns:
- Newly generated
UUID
-
construct
Method that will construct actualUUIDinstance 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, Reordered UUID constructed for given timestamp
- Since:
- 4.3
-