blob: 37f3eb8c1b63b535c3c03f78ab29a5a053925fab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package com.mavlushechka.a1qa.utils;
import java.util.OptionalInt;
import java.util.Random;
public class IntegerUtils {
private IntegerUtils() {
}
public static int getRandomNumber(int min, int max) {
OptionalInt randomNumber = new Random().ints(min, max).findFirst();
if (randomNumber.isPresent()) {
return randomNumber.getAsInt();
}
LoggerUtils.error("Incorrect min and max arguments.");
throw new IllegalArgumentException("Incorrect min and max arguments.");
}
}
|