T - type of created random generatorpublic final class RandomGeneratorFactory<T extends RandomGenerator> extends Object
RandomGeneratorFactory also provides methods for selecting random number generator algorithms. A specific RandomGeneratorFactory can be located by using the of(String) method, where the argument string is the name of the algorithm required. The method all() produces a non-empty Stream of all available RandomGeneratorFactorys that can be searched to locate a RandomGeneratorFactory suitable to the task. There are three methods for constructing a RandomGenerator instance, depending on the type of initial seed required. create(long) is used for long seed construction, create(byte[]) is used for byte[] seed construction, and create() is used for random seed construction. Example;    RandomGeneratorFactory<RandomGenerator> factory = RandomGeneratorFactory.of("Random");
    for (int i = 0; i < 10; i++) {
        new Thread(() -> {
            RandomGenerator random = factory.create(100L);
            System.out.println(random.nextDouble());
        }).start();
    }
all(). In this example, the code locates the RandomGeneratorFactory that produces RandomGenerators with the highest number of state bits.     RandomGeneratorFactory<RandomGenerator> best = RandomGeneratorFactory.all()
        .filter(rgf -> !rgf.name().equals("SecureRandom")) // SecureRandom has MAX_VALUE stateBits.
        .sorted(Comparator.comparingInt(RandomGeneratorFactory<RandomGenerator>::stateBits).reversed())
        .findFirst()
        .orElse(RandomGeneratorFactory.of("Random"));
    System.out.println(best.name() + " in " + best.group() + " was selected");
    RandomGenerator rng = best.create();
    System.out.println(rng.nextLong());
| Modifier and Type | Method | Description | 
|---|---|---|
| static Stream | all() | Returns a non-empty stream of available  RandomGeneratorFactory(s). | 
| T | create() | Create an instance of  RandomGeneratorbased on algorithm chosen. | 
| T | create | Create an instance of  RandomGeneratorbased on algorithm chosen providing a starting byte[] seed. | 
| T | create | Create an instance of  RandomGeneratorbased on algorithm chosen providing a starting long seed. | 
| int | equidistribution() | Returns the equidistribution of the algorithm. | 
| static RandomGeneratorFactory | getDefault() | Returns a  RandomGeneratorFactorymeeting the minimal requirement of having an algorithm whose state bits are greater than or equal 64. | 
| String | group() | Return the group name of the algorithm used by the random number generator. | 
| boolean | isArbitrarilyJumpable() | Return true if random generator can jump an arbitrarily specified distant point in the state cycle. | 
| boolean | isDeprecated() | Return true if the implementation of RandomGenerator (algorithm) has been marked for deprecation. | 
| boolean | isHardware() | Return true if random generator uses a hardware device (HRNG) to produce entropic input. | 
| boolean | isJumpable() | Return true if random generator can jump a specified distant point in the state cycle. | 
| boolean | isLeapable() | Return true if random generator is jumpable and can leap to a very distant point in the state cycle. | 
| boolean | isSplittable() | Return true if random generator can be cloned into a separate object with the same properties but positioned further in the state cycle. | 
| boolean | isStatistical() | Return true if random generator is computed using an arithmetic algorithm and is statistically deterministic. | 
| boolean | isStochastic() | Return true if random generator is computed using external or entropic sources as inputs. | 
| boolean | isStreamable() | Return true if random generator can be used to create  Streamsof random numbers. | 
| String | name() | Return the name of the algorithm used by the random number generator. | 
| static <T extends RandomGenerator> | of | Returns a  RandomGeneratorFactorythat can produce instances ofRandomGeneratorthat utilize thenamealgorithm. | 
| BigInteger | period() | Return the period of the algorithm used by the random number generator. | 
| int | stateBits() | Returns number of bits used by the algorithm to maintain state of seed. | 
public static <T extends RandomGenerator> RandomGeneratorFactory<T> of(String name)
RandomGeneratorFactory that can produce instances of RandomGenerator that utilize the name algorithm.T - Sub-interface of RandomGenerator to producename - Name of random number generator algorithm
RandomGeneratorFactory of RandomGenerator
NullPointerException - if name is nullIllegalArgumentException - if the named algorithm is not foundpublic static RandomGeneratorFactory<RandomGenerator> getDefault()
RandomGeneratorFactory meeting the minimal requirement of having an algorithm whose state bits are greater than or equal 64.RandomGeneratorFactory
public static Stream<RandomGeneratorFactory<RandomGenerator>> all()
RandomGeneratorFactory(s). RandomGenerators that are marked as deprecated are not included in the result.RandomGeneratorFactory(s).public String name()
public String group()
public int stateBits()
public int equidistribution()
public BigInteger period()
public boolean isStatistical()
public boolean isStochastic()
public boolean isHardware()
public boolean isArbitrarilyJumpable()
public boolean isJumpable()
public boolean isLeapable()
public boolean isSplittable()
public boolean isStreamable()
Streams of random numbers.public boolean isDeprecated()
public T create()
RandomGenerator based on algorithm chosen.RandomGenerator.public T create(long seed)
RandomGenerator based on algorithm chosen providing a starting long seed. If long seed is not supported by an algorithm then the no argument form of create is used.seed - long random seed value.RandomGenerator.public T create(byte[] seed)
RandomGenerator based on algorithm chosen providing a starting byte[] seed. If byte[] seed is not supported by an algorithm then the no argument form of create is used.seed - byte array random seed value.RandomGenerator.NullPointerException - if seed is null.
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/random/RandomGeneratorFactory.html