List of utility methods to do ThreadLocalRandom
String | base62Random() base Random return base62ToString(Math.abs(ThreadLocalRandom.current().nextLong()));
|
int | createNewPin() create New Pin int randomNum = ThreadLocalRandom.current().nextInt(1, 10000); return randomNum; |
String | createRandom(int number) create Random long min = (long) Math.pow(10, number - 1) + 1; long max = (long) Math.pow(10, number) - 1; long result = (long) ThreadLocalRandom.current().nextDouble(min, max); return result + ""; |
String | createRandomName() create Random Name return ("uniqueDb" + UUID.randomUUID() + ThreadLocalRandom.current().nextLong()).replaceAll("-", "") .toLowerCase(); |
String | createRandomNumbers(int length) create Random Numbers String numbers = ""; for (int i = 0; i < length; ++i) { int randomNumber = ThreadLocalRandom.current().nextInt(0, 9); numbers += Integer.toString(randomNumber); return numbers; |
String | generateDescription() Generates a description for a random part using the arrays of constants #SIZE , #COLOUR , #SHAPE , #MATERIAL , and #NOUN . ThreadLocalRandom r = ThreadLocalRandom.current(); StringBuilder sb = new StringBuilder(40); sb.append(SIZE[r.nextInt(SIZE.length)]); sb.append(' '); sb.append(COLOUR[r.nextInt(COLOUR.length)]); sb.append(' '); sb.append(SHAPE[r.nextInt(SHAPE.length)]); sb.append(' '); ... |
double[] | generateRandomDoubleVector(int dimension, double bottomLimit, double topLimit) generate Random Double Vector double[] position = new double[dimension]; for (int i = 0; i < dimension; i++) { position[i] = ThreadLocalRandom.current().nextDouble(bottomLimit, topLimit); return position; |
int | generateRandomisedId() Generate a randomized integer over [ Integer#MIN_VALUE , Integer#MAX_VALUE ] suitable for use as an Aeron Id. return ThreadLocalRandom.current().nextInt();
|
byte[] | generateRandomSalt(int saltSize) generate Random Salt byte[] randomSalt = new byte[saltSize]; ThreadLocalRandom.current().nextBytes(randomSalt); return randomSalt; |
String | generateString(int length) generate String StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { int index = ThreadLocalRandom.current().nextInt(allChar.length()); sb.append(allChar.charAt(index)); return sb.toString(); |