public final class RandomExtensions
extends java.lang.Object
| Constructor and Description |
|---|
RandomExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
getRandomEntry(java.util.List<T> list)
Returns a random entry from the given List.
|
static <K,V> java.lang.Object |
getRandomEntry(java.util.Map<K,V> map)
Returns a random entry from the given map.
|
static <T extends java.lang.Enum<?>> |
getRandomEnumFromClass(java.lang.Class<T> clazz)
Gets the random enum.
|
static <T extends java.lang.Enum<?>> |
getRandomEnumFromClassname(java.lang.String classname)
Gets the random enum.
|
static <T extends java.lang.Enum<?>> |
getRandomEnumFromEnumValues(T[] values)
Gets the random enum.
|
static <T extends java.lang.Enum<?>> |
getRandomEnumFromObject(T obj)
Gets the random enum.
|
static java.lang.String |
getRandomHexString(int numberOfCharacters)
Generates a random hexadecimal
String |
static <T> int |
getRandomIndex(java.util.Collection<T> list)
Returns a random index from the given List.
|
static <K,V> java.lang.Object |
getRandomKey(java.util.Map<K,V> map)
Returns a random key from the given map.
|
static byte[] |
getRandomSalt(int length,
java.nio.charset.Charset charset)
Gets the random salt.
|
static java.lang.String |
getRandomString()
Generates a random string with a length between 3 and 25
|
static java.lang.String |
getRandomString(int length)
Generates a random string.
|
static java.lang.String |
getRandomString(int start,
int end)
Generates a random string with a length between the given start and end
|
static java.lang.String |
getRandomString(java.lang.String[] array)
The Method randomString(String []) a random String from the Array For example: The
Stringarray test as argument.
|
static java.lang.String |
getRandomString(java.lang.String chars,
int length)
The Method randomString(String, int) makes an random String from the given String and to the
spezified length.
|
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 java.math.BigInteger |
randomSerialNumber()
Returns a random serial number that can be used for a serial number.
|
static java.lang.String |
randomToken()
Returns a random token for use in web services.
|
static java.util.UUID |
randomUUID()
Factory method for create a new random
UUID |
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 <T> T getRandomEntry(java.util.List<T> list)
T - the generic typelist - The List.public static <K,V> java.lang.Object getRandomEntry(java.util.Map<K,V> map)
K - the key typeV - the value typemap - The map.public static <T extends java.lang.Enum<?>> T getRandomEnumFromClass(java.lang.Class<T> clazz)
T - the generic typeclazz - the clazzpublic static <T extends java.lang.Enum<?>> T getRandomEnumFromClassname(java.lang.String classname)
T - the generic typeclassname - the classnamepublic static <T extends java.lang.Enum<?>> T getRandomEnumFromObject(T obj)
T - the generic typeobj - the objpublic static <T extends java.lang.Enum<?>> T getRandomEnumFromEnumValues(T[] values)
T - the generic typevalues - the valuespublic static <T> int getRandomIndex(java.util.Collection<T> list)
T - the generic typelist - The List.public static <K,V> java.lang.Object getRandomKey(java.util.Map<K,V> map)
K - the key typeV - the value typemap - The map.public static java.lang.String getRandomString(int length)
length - the specified length.public static java.lang.String getRandomHexString(int numberOfCharacters)
StringnumberOfCharacters - the number of charactersStringpublic static java.lang.String getRandomString(java.lang.String chars,
int length)
chars - The String to get the random chars.length - The length from the random String.public static java.lang.String getRandomString()
public static java.lang.String getRandomString(int start,
int end)
start - the startend - the endpublic static java.lang.String getRandomString(java.lang.String[] array)
array - The array with the String to be selected.public static java.util.UUID randomUUID()
UUIDUUIDpublic static java.lang.String randomToken()
public static java.math.BigInteger randomSerialNumber()
BigInteger object.public static byte[] newSalt()
public static byte[] getRandomSalt(int length,
java.nio.charset.Charset charset)
length - the lengthcharset - the charset