public final class JDKRandomBridge extends Random
Random
that delegates
to a
RestorableUniformRandomProvider
instance but will otherwise rely
on the base class for generating all the random types.
Legacy applications coded against the JDK's API could use this subclass
of Random
in order to replace its linear congruential generator
by any RandomSource
.
Constructor and Description |
---|
JDKRandomBridge(RandomSource source,
Object seed)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected int |
next(int n)
Delegates the generation of 32 random bits to the
RandomSource argument provided at
construction . |
void |
setSeed(long seed) |
public JDKRandomBridge(RandomSource source, Object seed)
source
- Source of randomness.seed
- Seed. Can be null
.protected int next(int n)
RandomSource
argument provided at
construction
.
The returned value is such that if the source of randomness is
RandomSource.JDK
, all the generated values will be identical
to those produced by the same sequence of calls on a Random
instance initialized with the same seed.Copyright © 2016 The Apache Software Foundation. All rights reserved.