Class RandomBasedFactory


  • public final class RandomBasedFactory
    extends AbstRandomBasedFactory
    Concrete factory for creating random-based unique identifiers (UUIDv4).
    • Constructor Detail

      • RandomBasedFactory

        public RandomBasedFactory()
        Default constructor.
      • RandomBasedFactory

        public RandomBasedFactory​(Random random)
        Constructor with a Random instance.
        Parameters:
        random - a Random instance
      • RandomBasedFactory

        public RandomBasedFactory​(LongSupplier randomSupplier)
        Constructor with a function which returns random number.
        Parameters:
        randomSupplier - a function
    • Method Detail

      • create

        public UUID create()
        Returns a random-based UUID. ### RFC 9562 - 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:
        create in class UuidFactory
        Returns:
        a random-based UUID