public final class RandomExtensions extends Object
| Constructor and Description |
|---|
RandomExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static BigDecimal |
getRandomBigDecimal(int afterComma,
int beforeComma)
The Method getRandomBigDecimal(int,int) gets an random BigDecimal.
|
static Byte |
getRandomByte()
The Method getRandomByte() selects a random Byte object.
|
static Byte[] |
getRandomByteArray(int length)
The Method getRandomByteArray(int) generates a random Byte array.
|
static <T> T |
getRandomEntry(List<T> list)
Returns a random entry from the given List.
|
static <K,V> Object |
getRandomEntry(Map<K,V> map)
Returns a random entry from the given map.
|
static <T extends Enum<?>> |
getRandomEnumFromClass(Class<T> clazz)
Gets the random enum.
|
static <T extends Enum<?>> |
getRandomEnumFromClassname(String classname)
Gets the random enum.
|
static <T extends Enum<?>> |
getRandomEnumFromEnumValues(T[] values)
Gets the random enum.
|
static <T extends Enum<?>> |
getRandomEnumFromObject(T obj)
Gets the random enum.
|
static Float |
getRandomFloat(int afterComma,
int beforeComma)
The Method getRandomFloat(int,int) gets an random float.
|
static String |
getRandomHexString(int numberOfCharacters)
Generates a random hexadecimal
String |
static <T> int |
getRandomIndex(Collection<T> list)
Returns a random index from the given List.
|
static <K,V> Object |
getRandomKey(Map<K,V> map)
Returns a random key from the given map.
|
static String |
getRandomNumericString()
Generates a random numeric string.
|
static String |
getRandomNumericString(int length)
The Method getRandomNumericString(int) produces a random Number to the specified length.
|
static byte[] |
getRandomPrimitiveByteArray(int length)
The Method getRandomPrimitiveByteArray(int) generates a random byte array.
|
static byte[] |
getRandomSalt(int length,
Charset charset)
Gets the random salt.
|
static String |
getRandomString()
Generates a random string with a length between 3 and 25
|
static String |
getRandomString(int length)
Generates a random string.
|
static String |
getRandomString(int start,
int end)
Generates a random string with a length between the given start and end
|
static String |
getRandomString(String[] array)
The Method randomString(String []) a random String from the Array For example: The
Stringarray test as argument.
|
static String |
getRandomString(String chars,
int length)
The Method randomString(String, int) makes an random String from the given String and to the
spezified length.
|
static SecureRandom |
getSecureRandom()
Gets the secure random.
|
static int |
newRandomPixel()
Generates a random int for use with pixel.
|
static int |
newRandomPixel(int red,
int green,
int blue,
int alpha)
Generates a random int for use with pixel.
|
static byte[] |
newSalt()
Factory method for create a new random salt.
|
static BigDecimal |
randomBigDecimal()
Generates a random
BigDecimal |
static BigInteger |
randomBigInteger()
Generates a random
BigInteger |
static boolean |
randomBoolean()
Returns a random boolean.
|
static byte |
randomByte()
The Method randomByte() selects a random byte.
|
static byte[] |
randomByteArray(int length)
The Method randomByteArray(int) generates a random byte array.
|
static char |
randomChar()
Returns a random char.
|
static char |
randomChar(String string)
The Method randomChar(String) selects a random char from the given String.
|
static double |
randomDouble()
The Method randomDouble() gets a random double
|
static double |
randomDouble(double range)
The Method randomDouble(double) gets an double to the spezified range.
|
static double |
randomDoubleBetween(double start,
double end)
Gets the random double between the range from start and end.
|
static double |
randomDoubleBetween(double start,
double end,
String pattern)
Gets the random double between the range from start and end in the given pattern.
|
static float |
randomFloat()
Generates a random float between the range 0.0-9.9.
|
static float |
randomFloat(float range)
The Method randomFloat(float) gets an float to the spezified range.
|
static float |
randomFloat(int afterComma,
int beforeComma)
The Method getRandomFloat(int,int) gets an random float.
|
static float |
randomFloatBetween(float start,
float end)
Gets the random float between the range from start and end.
|
static float |
randomFloatBetween(float start,
float end,
String pattern)
Gets the random float between the range from start and end in the given pattern.
|
static int |
randomInt()
The Method randomInt() gets an int between the range 0-9.
|
static int |
randomInt(int range)
The Method randomInt(int) gets an int to the spezified range.
|
static int |
randomIntBetween(int start,
int end)
Returns a random int between the range from start and end.
|
static int |
randomIntBetween(int start,
int end,
boolean includeMin,
boolean includeMax)
Returns a random int between the range from start and end.
|
static long |
randomLong()
Gets a random long
|
static long |
randomLong(long range)
The Method randomLong(long) gets an long to the spezified range.
|
static long |
randomLongBetween(long start,
long end)
Returns a random long between the range from start and end.
|
static BigInteger |
randomSerialNumber()
Returns a random serial number that can be used for a serial number.
|
static short |
randomShort()
Returns a random short
|
static String |
randomToken()
Returns a random token for use in web services.
|
static UUID |
randomUUID()
Factory method for create a new random
UUID |
public static long randomLong()
public static long randomLong(long range)
range - the rangepublic static long randomLongBetween(long start,
long end)
start - The long from where the range starts.end - The long from where the range ends.public static float randomFloat()
public static SecureRandom getSecureRandom()
public static int newRandomPixel()
public static int newRandomPixel(int red,
int green,
int blue,
int alpha)
red - The red value.green - The green value.blue - The blue value.alpha - The alpha value.public static BigDecimal getRandomBigDecimal(int afterComma, int beforeComma)
afterComma - How many decimal places after the comma.beforeComma - How many decimal places before the comma.public static Byte getRandomByte()
public static Byte[] getRandomByteArray(int length)
length - the length.public static <T> T getRandomEntry(List<T> list)
T - the generic typelist - The List.public static <K,V> Object getRandomEntry(Map<K,V> map)
K - the key typeV - the value typemap - The map.public static <T extends Enum<?>> T getRandomEnumFromClass(Class<T> clazz)
T - the generic typeclazz - the clazzpublic static <T extends Enum<?>> T getRandomEnumFromClassname(String classname)
T - the generic typeclassname - the classnamepublic static <T extends Enum<?>> T getRandomEnumFromObject(T obj)
T - the generic typeobj - the objpublic static <T extends Enum<?>> T getRandomEnumFromEnumValues(T[] values)
T - the generic typevalues - the valuespublic static Float getRandomFloat(int afterComma, int beforeComma)
afterComma - How many decimal places after the comma.beforeComma - How many decimal places before the comma.public static <T> int getRandomIndex(Collection<T> list)
T - the generic typelist - The List.public static <K,V> Object getRandomKey(Map<K,V> map)
K - the key typeV - the value typemap - The map.public static String getRandomNumericString()
public static String getRandomNumericString(int length)
length - The length from the random number.public static String getRandomString(int length)
length - the specified length.public static String getRandomHexString(int numberOfCharacters)
StringnumberOfCharacters - the number of charactersStringpublic static String getRandomString(String chars, int length)
chars - The String to get the random chars.length - The length from the random String.public static String getRandomString()
public static String getRandomString(int start, int end)
start - the startend - the endpublic static String getRandomString(String[] array)
array - The array with the String to be selected.public static boolean randomBoolean()
public static byte randomByte()
public static byte[] randomByteArray(int length)
length - the length.public static char randomChar()
public static short randomShort()
public static char randomChar(String string)
string - The String from who to select the char.public static double randomDouble(double range)
range - the rangepublic static double randomDouble()
public static double randomDoubleBetween(double start,
double end)
start - the startend - the endpublic static double randomDoubleBetween(double start,
double end,
String pattern)
throws ParseException
DecimalFormat.start - the startend - the endpattern - the patternParseException - is thrown if the beginning of the specified string cannot be parsedpublic static float randomFloat(float range)
range - the rangepublic static float randomFloat(int afterComma,
int beforeComma)
afterComma - How many decimal places after the comma.beforeComma - How many decimal places before the comma.public static float randomFloatBetween(float start,
float end)
start - the startend - the endpublic static float randomFloatBetween(float start,
float end,
String pattern)
throws ParseException
DecimalFormat.start - the startend - the endpattern - the patternParseException - is thrown if the beginning of the specified string cannot be parsedpublic static int randomInt()
public static UUID randomUUID()
UUIDUUIDpublic static int randomInt(int range)
range - The Range.public static int randomIntBetween(int start,
int end)
start - The int from where the range starts.end - The int from where the range ends.public static int randomIntBetween(int start,
int end,
boolean includeMin,
boolean includeMax)
start - The int from where the range starts.end - The int from where the range ends.includeMin - if true than min value is includedincludeMax - if true than max value is includedpublic static String randomToken()
public static BigInteger randomSerialNumber()
BigInteger object.public static byte[] getRandomPrimitiveByteArray(int length)
length - the length.public static byte[] newSalt()
public static byte[] getRandomSalt(int length,
Charset charset)
length - the lengthcharset - the charsetpublic static BigInteger randomBigInteger()
BigIntegerBigIntegerpublic static BigDecimal randomBigDecimal()
BigDecimalBigDecimalCopyright © 2015–2019 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.