Summary
Introduce methods to simplify the selection of basic RandomGenerators.
Problem
Without using a specific algorithm, the RandomGenerator API recommends that the user should use a query to select an appropriate an algorithm. The queries could be daunting for a user that just wants a basic RandomGenerator. Ex.,
RandomGeneratorFactory<RandomGenerator> best = RandomGenerator.all()
.sorted((f, g) -> Integer.compare(f.stateBits(), g.stateBits()))
.findFirst()
.orElseThrow();
Solution
Provide methods that return a basic RandomGenerator or RandomGeneratorFactory.
Specification
/**
* Returns a {@link RandomGeneratorFactory} meeting the minimal requirement
* of having an algorithm whose state bits are greater than or equal 64.
*
* @implNote Since algorithms will improve over time, there is no
* guarantee that this method will return the same algorithm each time.
*
* @return a {@link RandomGeneratorFactory}
*/
static RandomGeneratorFactory<RandomGenerator> getDefaultFactory() {
return factoryOf("L32X64MixRandom");
}
/**
* Returns a {@link RandomGenerator} meeting the minimal requirement
* of having an algorithm whose state bits are greater than or equal 64.
*
* @implNote Since algorithms will improve over time, there is no
* guarantee that this method will return the same algorithm each time.
*
* @return a {@link RandomGenerator}
*/
static RandomGenerator getDefault() {
return of("L32X64MixRandom");
}
- csr of
-
JDK-8259269 Add getDefault() methods to RandomGenerator
- Closed