public class RandomService extends Object
| Constructor and Description |
|---|
RandomService(Long seed) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
chance(int howMany,
int in,
Supplier<T> supplier)
Has a
howMany in in chance to supply a value. |
long |
getSeed() |
boolean |
nextBoolean()
Generates a random boolean
|
double |
nextDouble()
Generates a random positive double
|
double |
nextDouble(double bound)
Generates a random double between 0 and
upperBound (inclusive) |
double |
nextDouble(double lowerBound,
double upperBound)
Generates a random double between
lowerBound and upperBound (inclusive) |
float |
nextFloat()
Generates a random positive float
|
float |
nextFloat(float upperBound)
Generates a random double between 0 and
upperBound (inclusive) |
float |
nextFloat(float lowerBound,
float upperBound)
Generates a random float between
lowerBound (inclusive) and upperBound (exclusive) |
int |
nextInt()
Generates a random positive int
|
int |
nextInt(int upperBound)
Generates a random int between 0 and
upperBound (inclusive) |
int |
nextInt(int lowerBound,
int upperBound)
Generates a random int between
lowerBound and upperBound (inclusive) |
long |
nextLong()
Generates a random positive long
|
long |
nextLong(long upperBound)
Generates a random long between 0 and
upperBound inclusive |
long |
nextLong(long lowerBound,
long upperBound)
Generates a random long between @{code lowerBound} and
upperBound (inclusive) |
public RandomService(Long seed)
public long getSeed()
public <T> T chance(int howMany,
int in,
Supplier<T> supplier)
howMany in in chance to supply a value. Otherwise, returns null.
E.g. chance(1, 2, () -> "hello") has a 1-in-2 chance to supply "hello", that is it will be supplied
50% of the time when the method is invoked.
T or nullpublic boolean nextBoolean()
public int nextInt()
public int nextInt(int upperBound)
upperBound (inclusive)public int nextInt(int lowerBound,
int upperBound)
lowerBound and upperBound (inclusive)public long nextLong()
public long nextLong(long lowerBound,
long upperBound)
upperBound (inclusive)public long nextLong(long upperBound)
upperBound inclusivepublic double nextDouble()
public double nextDouble(double bound)
upperBound (inclusive)public double nextDouble(double lowerBound,
double upperBound)
lowerBound and upperBound (inclusive)public float nextFloat()
public float nextFloat(float upperBound)
upperBound (inclusive)public float nextFloat(float lowerBound,
float upperBound)
lowerBound (inclusive) and upperBound (exclusive)Copyright © 2020. All rights reserved.