summaryrefslogtreecommitdiff
path: root/src/main/java/com/mavlushechka/a1qa/framework/utils/IntegerUtils.java
blob: 0c31639a8a272951e6ae24c5e054b8b8500b9303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.mavlushechka.a1qa.framework.utils;

import aquality.selenium.browser.AqualityServices;

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();
        }
        AqualityServices.getLogger().error("Incorrect min and max arguments.");
        throw new IllegalArgumentException("Incorrect min and max arguments.");
    }

    public static int parseInt(String text) {
        return Integer.parseInt(text.replaceAll("[^0-9.]", ""));
    }

}