Package org.drasyl.util
Class RandomUtil
java.lang.Object
org.drasyl.util.RandomUtil
Utility class for receiving pseudorandom values.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byteReturns a single pseudorandom byte.static byte[]randomBytes(int count) Returns an array of lengthcountcontaining pseudorandom bytes.static intrandomInt(int max) Returns a pseudorandom, uniformly distributedintvalue between 0 andmax.static intrandomInt(int min, int max) Returns a pseudorandom, uniformly distributedintvalue betweenminandmax.static longrandomLong(long max) Returns a pseudorandom, uniformly distributedlongvalue between 0 andmax.static longrandomLong(long min, long max) Returns a pseudorandom, uniformly distributedlongvalue betweenminandmax.static StringrandomString(int length) Returns a string of the givenlengthcontaining pseudorandom alphanumeric characters.
-
Method Details
-
randomInt
public static int randomInt(int min, int max) Returns a pseudorandom, uniformly distributedintvalue betweenminandmax.- Parameters:
min- The lowest value to returnmax- The highest value to return- Returns:
- Pseudorandom
int - Throws:
IllegalArgumentException- ifminis greater thenmax
-
randomInt
public static int randomInt(int max) Returns a pseudorandom, uniformly distributedintvalue between 0 andmax.- Parameters:
max- The highest value to return- Returns:
- Pseudorandom
int
-
randomLong
public static long randomLong(long min, long max) Returns a pseudorandom, uniformly distributedlongvalue betweenminandmax.- Parameters:
min- The lowest value to returnmax- The highest value to return- Returns:
- Pseudorandom
long - Throws:
IllegalArgumentException- ifminis greater thenmax
-
randomLong
public static long randomLong(long max) Returns a pseudorandom, uniformly distributedlongvalue between 0 andmax.- Parameters:
max- The highest value to return- Returns:
- Pseudorandom
long
-
randomBytes
public static byte[] randomBytes(int count) Returns an array of lengthcountcontaining pseudorandom bytes.- Parameters:
count- The length of the array- Returns:
- Array containing pseudorandom bytes
-
randomByte
public static byte randomByte()Returns a single pseudorandom byte.- Returns:
- a pseudorandom byte
-
randomString
Returns a string of the givenlengthcontaining pseudorandom alphanumeric characters.- Parameters:
length- The length of the string- Returns:
- string containing pseudorandom alphanumeric characters
-