public class TimeBasedGenerator extends NoArgGenerator
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).
Modifier and Type | Field and Description |
---|---|
protected EthernetAddress |
_ethernetAddress |
protected UUIDTimer |
_timer
Object used for synchronizing access to timestamps, to guarantee
that timestamps produced by this generator are unique and monotonically increasings.
|
protected long |
_uuidL2
Base values for the second long (last 8 bytes) of UUID to construct
|
Constructor and Description |
---|
TimeBasedGenerator(EthernetAddress ethAddr,
UUIDTimer timer) |
Modifier and Type | Method and Description |
---|---|
UUID |
construct(long rawTimestamp)
Method that will construct actual
UUID instance for given
timestamp: called by generate() but may alternatively be
called directly to construct an instance with known timestamp. |
UUID |
generate()
Method for generating a
UUID . |
EthernetAddress |
getEthernetAddress() |
UUIDType |
getType()
Accessor for determining type of UUIDs (version) that this
generator instance will produce.
|
protected final EthernetAddress _ethernetAddress
protected final UUIDTimer _timer
protected final long _uuidL2
public TimeBasedGenerator(EthernetAddress ethAddr, UUIDTimer timer)
ethAddr
- Hardware address (802.1) to use for generating
spatially unique part of UUID. If system has more than one NIC,public UUIDType getType()
UUIDGenerator
getType
in class UUIDGenerator
public EthernetAddress getEthernetAddress()
public UUID generate()
NoArgGenerator
UUID
.generate
in class NoArgGenerator
UUID
public UUID construct(long rawTimestamp)
UUID
instance for given
timestamp: called by generate()
but may alternatively be
called directly to construct an instance with known timestamp.
NOTE: calling this method directly does NOT guarantee uniqueness of resulting
UUID
(caller has to guarantee uniqueness)rawTimestamp
- Timestamp usually obtained from UUIDTimer.getTimestamp()
,
used for constructing UUID instanceCopyright © 2023 FasterXML.com. All rights reserved.