- All Superinterfaces:
-
RandomGenerator
- All Known Subinterfaces:
-
RandomGenerator.ArbitrarilyJumpableGenerator
,RandomGenerator.JumpableGenerator
,RandomGenerator.LeapableGenerator
,RandomGenerator.SplittableGenerator
- All Known Implementing Classes:
-
RandomSupport.AbstractArbitrarilyJumpableGenerator
,RandomSupport.AbstractSplittableGenerator
,RandomSupport.AbstractSplittableWithBrineGenerator
,SplittableRandom
- Enclosing interface:
- RandomGenerator
public static interface RandomGenerator.StreamableGenerator extends RandomGenerator
RandomGenerator.StreamableGenerator
interface augments the RandomGenerator
interface to provide methods that return streams of RandomGenerator
objects. Ideally, such a stream of objects would have the property that the behavior of each object is statistically independent of all the others. In practice, one may have to settle for some approximation to this property.
A generator that implements interface RandomGenerator.SplittableGenerator
may choose to use its splits
() method to implement the rngs
() method required by this interface.
A generator that implements interface RandomGenerator.JumpableGenerator
may choose to use its jumps
() method to implement the rngs
() method required by this interface.
A generator that implements interface RandomGenerator.LeapableGenerator
may choose to use its leaps
() method to implement the rngs
() method required by this interface.
An implementation of the RandomGenerator.StreamableGenerator
interface must provide concrete definitions for the methods nextLong
(), rngs
(). Default implementations are provided for all other methods.
Objects that implement RandomGenerator.StreamableGenerator
are typically not cryptographically secure. Consider instead using SecureRandom
to get a cryptographically secure pseudo-random number generator for use by security-sensitive applications.
- Since:
- 16
-
Nested Class Summary
Nested classes/interfaces declared in interface java.util.random.RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.RandomGeneratorProperty, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator
-
Field Summary
Fields declared in interface java.util.random.RandomGenerator
HUGE_PERIOD, TRULY_RANDOM, UNKNOWN_PERIOD
-
Method Summary
Modifier and TypeMethodDescriptionall()
Returns a stream of all availableRandomGenerator.StreamableGenerator
factories.Returns aRandomGeneratorFactory
that can produce instances ofRandomGenerator.StreamableGenerator
that utilize thename
algorithm.Returns an instance ofRandomGenerator.StreamableGenerator
that utilizes thename
algorithm.rngs()
Returns an effectively unlimited stream of objects, each of which implements theRandomGenerator
interface.default Stream<RandomGenerator>
rngs(long streamSize)
Returns an effectively unlimited stream of objects, each of which implements theRandomGenerator
interface.Methods declared in interface java.util.random.RandomGenerator
doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, nextBoolean, nextBytes, nextDouble, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextFloat, nextGaussian, nextGaussian, nextInt, nextInt, nextInt, nextLong, nextLong, nextLong
-
Method Details
-
all
Returns a stream of all availableRandomGenerator.StreamableGenerator
factories.- Returns:
-
Stream of all available
RandomGenerator.StreamableGenerator
factories.
-
of
Returns an instance ofRandomGenerator.StreamableGenerator
that utilizes thename
algorithm.- Parameters:
-
name
- Name of random number generator algorithm - Returns:
-
An instance of
RandomGenerator.StreamableGenerator
-
factoryOf
Returns aRandomGeneratorFactory
that can produce instances ofRandomGenerator.StreamableGenerator
that utilize thename
algorithm.- Parameters:
-
name
- Name of random number generator algorithm - Returns:
-
RandomGeneratorFactory
ofRandomGenerator.StreamableGenerator
-
rngs
Stream<RandomGenerator> rngs()Returns an effectively unlimited stream of objects, each of which implements theRandomGenerator
interface. Ideally the generators in the stream will appear to be statistically independent. The new generators should be of the same kind as this generator.- Implementation Note:
-
It is permitted to implement this method in a manner equivalent to
rngs
(Long.MAX_VALUE
). - Returns:
-
a stream of objects that implement the
RandomGenerator
interface
-
rngs
Returns an effectively unlimited stream of objects, each of which implements theRandomGenerator
interface. Ideally the generators in the stream will appear to be statistically independent. The new generators should be of the same kind as this generator.- Implementation Note:
-
The default implementation calls
rngs
() and then limits its length tostreamSize
. - Parameters:
-
streamSize
- the number of generators to generate - Returns:
-
a stream of objects that implement the
RandomGenerator
interface - Throws:
-
IllegalArgumentException
- ifstreamSize
is less than zero
-