Package com.fasterxml.uuid.impl
Class RandomBasedGenerator
java.lang.Object
com.fasterxml.uuid.UUIDGenerator
com.fasterxml.uuid.NoArgGenerator
com.fasterxml.uuid.impl.RandomBasedGenerator
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
FieldsModifier and TypeFieldDescriptionprotected final RandomRandom number generator that this generator uses.protected final booleanLooks likeSecureRandomimplementation is more efficient using single call access (compared to basicRandom), so let's use that knowledge to our benefit. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.fasterxml.uuid.UUIDGenerator
_toInt, _toLong, _toShort
-
Field Details
-
_random
Random number generator that this generator uses. -
_secureRandom
protected final boolean _secureRandomLooks likeSecureRandomimplementation is more efficient using single call access (compared to basicRandom), so let's use that knowledge to our benefit.
-
-
Constructor Details
-
RandomBasedGenerator
- Parameters:
rnd- Random number generator to use for generating UUIDs; if null, shared default generator is used. Note that it is strongly recommend to use a good (pseudo) random number generator; for example, JDK'sSecureRandom.
-
-
Method Details
-
getType
Description copied from class:UUIDGeneratorAccessor for determining type of UUIDs (version) that this generator instance will produce.- Specified by:
getTypein classUUIDGenerator
-
generate
Description copied from class:NoArgGeneratorMethod for generating aUUID.- Specified by:
generatein classNoArgGenerator- Returns:
- Newly generated
UUID
-