com.fasterxml.uuid.impl
Class RandomBasedGenerator
java.lang.Object
com.fasterxml.uuid.UUIDGenerator
com.fasterxml.uuid.NoArgGenerator
com.fasterxml.uuid.impl.RandomBasedGenerator
public class RandomBasedGenerator
- extends NoArgGenerator
Implementation of UUID generator that uses generation method 4.
Note on random number generation when using SecureRandom
for random number
generation: the first time SecureRandom
object is used, there is noticeable delay between
calling the method and getting the reply. This is because SecureRandom
has to initialize itself to reasonably random state. Thus, if you
want to lessen delay, it may be be a good idea to either get the
first random UUID asynchronously from a separate thread, or to
use the other generateRandomBasedUUID passing a previously initialized
SecureRandom instance.
- Since:
- 3.0
Field Summary |
protected Random |
_random
Random number generator that this generator uses. |
protected static Random |
_sharedRandom
Default shared random number generator, used if no random number generator
is explicitly specified for instance |
Method Summary |
UUID |
generate()
|
UUIDType |
getType()
Accessor for determining type of UUIDs (variant) that this
generator instance will produce. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_sharedRandom
protected static Random _sharedRandom
- Default shared random number generator, used if no random number generator
is explicitly specified for instance
_random
protected final Random _random
- Random number generator that this generator uses.
RandomBasedGenerator
public RandomBasedGenerator(Random rnd)
- Parameters:
rnd
- Random number generator to use for generating UUIDs; if null,
shared default generator is used. Note that it is strongly recommened to
use a good (pseudo) random number generator; for example, JDK's
SecureRandom
.
getType
public UUIDType getType()
- Description copied from class:
UUIDGenerator
- Accessor for determining type of UUIDs (variant) that this
generator instance will produce.
- Specified by:
getType
in class UUIDGenerator
generate
public UUID generate()
- Specified by:
generate
in class NoArgGenerator
Copyright © 2010 FasterXML.com. All Rights Reserved.