Package net.datafaker.service
Class RandomService
java.lang.Object
net.datafaker.service.RandomService
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
hex()
hex
(int length) hex
(int length, boolean upper) boolean
double
double
nextDouble
(double min, double max) float
int
nextInt()
int
nextInt
(int maxExclusive) nextInt
(int minInclusive, int maxInclusive) int
long
nextLong()
long
nextLong
(long maxExclusive) long
nextLong
(long min, long max) A random long value within given range.long
byte[]
nextRandomBytes
(int numberOfBytes) toString()
-
Constructor Details
-
RandomService
public RandomService()Uses a default shared random. -
RandomService
- Parameters:
random
- If null is passed in, a default Random is assigned
-
-
Method Details
-
nextInt
public int nextInt() -
nextInt
public int nextInt(int maxExclusive) -
nextInt
-
nextInt
-
nextFloat
public float nextFloat() -
nextLong
public long nextLong() -
nextLong
public long nextLong(long maxExclusive) -
nextLong
-
nextLong
public long nextLong(long min, long max) A random long value within given range. Ifmin == max
then method always returnsmin
. Otherwise,max
is exclusive.- Parameters:
min
- lower bound (inclusive)max
- upper bound (exclusive in most cases)- Returns:
- a random long value between
min
andmax
-
nextDouble
public double nextDouble() -
nextDouble
public double nextDouble(double min, double max) - Parameters:
min
- (inclusive)max
- (inclusive)- Returns:
- a random double value between
min
andmax
(both inclusive)
-
nextBoolean
public boolean nextBoolean() -
nextRandomBytes
public byte[] nextRandomBytes(int numberOfBytes) -
hex
-
hex
-
hex
-
getRandomInternal
-
equals
-
hashCode
public int hashCode() -
toString
-