- java.lang.Object
-
- com.github.f4b6a3.uuid.factory.UuidFactory
-
- com.github.f4b6a3.uuid.factory.AbstRandomBasedFactory
-
- All Implemented Interfaces:
NoArgsFactory
- Direct Known Subclasses:
PrefixCombFactory,RandomBasedFactory,ShortPrefixCombFactory,ShortSuffixCombFactory,SuffixCombFactory
public abstract class AbstRandomBasedFactory extends UuidFactory implements NoArgsFactory
Factory that creates random-based UUIDs.
-
-
Field Summary
Fields Modifier and Type Field Description protected RandomFunctionrandomFunctionprotected static intUUID_BYTES-
Fields inherited from class com.github.f4b6a3.uuid.factory.UuidFactory
version, versionMask
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstRandomBasedFactory(UuidVersion version, RandomFunction randomFunction)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UUIDcreate()Returns a random-based UUID. ### RFC-4122 - 4.4.protected static RandomFunctiongetRandomFunction(Random random)It instantiates a function that returns a byte array of a given length.-
Methods inherited from class com.github.f4b6a3.uuid.factory.UuidFactory
getUuid, getUuid, getVersion
-
-
-
-
Field Detail
-
randomFunction
protected RandomFunction randomFunction
-
UUID_BYTES
protected static final int UUID_BYTES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstRandomBasedFactory
protected AbstRandomBasedFactory(UuidVersion version, RandomFunction randomFunction)
-
-
Method Detail
-
create
public UUID create()
Returns a random-based UUID. ### RFC-4122 - 4.4. Algorithms for Creating a UUID from Truly Random or Pseudo-Random Numbers (1) Set the two most significant bits (bits 6 and 7) of the clock_seq_hi_and_reserved to zero and one, respectively. (2) Set the four most significant bits (bits 12 through 15) of the time_hi_and_version field to the 4-bit version number from Section 4.1.3. (3) Set all the other bits to randomly (or pseudo-randomly) chosen values.- Specified by:
createin interfaceNoArgsFactory- Returns:
- a random-based UUID
-
getRandomFunction
protected static RandomFunction getRandomFunction(Random random)
It instantiates a function that returns a byte array of a given length. If the a null parameter is given,DefaultRandomFunctionis implied.- Parameters:
random- aRandomgenerator- Returns:
- a random function that returns a byte array of a given length
-
-