package com.fwdekker.randomness.integer;

import com.fwdekker.randomness.InsertRandomSomething;
import java.security.SecureRandom;
import java.util.Random;
import org.jetbrains.annotations.NotNull;


/**
 * Generates a random integer based on the settings in {@link IntegerSettings}.
 */
public final class InsertRandomInteger extends InsertRandomSomething {
    private static final Random RANDOM = new SecureRandom();

    private final IntegerSettings integerSettings;


    /**
     * Constructs a new {@code InsertRandomInteger} that uses the singleton {@code IntegerSettings} instance.
     */
    public InsertRandomInteger() {
        this.integerSettings = IntegerSettings.getInstance();
    }

    /**
     * Constructs a new {@code InsertRandomInteger} that uses the given {@code IntegerSettings} instance.
     *
     * @param integerSettings the settings to use for generating integers
     */
    InsertRandomInteger(@NotNull final IntegerSettings integerSettings) {
        this.integerSettings = integerSettings;
    }


    /**
     * Returns a random integer between the minimum and maximum value, inclusive.
     *
     * @return a random integer between the minimum and maximum value, inclusive
     */
    @Override
    public String generateString() {
        final long range = integerSettings.getMaxValue() - integerSettings.getMinValue();
        final long randomValue = integerSettings.getMinValue() + RANDOM.nextLong() * range;

        return Long.toString(randomValue);
    }
}

@@ -105,48 +105,35 @@
 ava.
-security.SecureRandom;%0Aimport java.util.
+util.concurrent.ThreadLocal
 Rand
@@ -343,70 +343,8 @@
 g %7B%0A
-    private static final Random RANDOM = new SecureRandom();%0A%0A
     
@@ -1218,108 +1218,103 @@
  ran
-ge = integerSettings.getMaxValue() - integerSettings.getMinValue();%0A        final long randomValue =
+domValue = ThreadLocalRandom.current()%0A                .nextLong(integerSettings.getMinValue(),
  int
@@ -1326,26 +1326,26 @@
 ettings.getM
-in
+ax
 Value() + RA
@@ -1346,33 +1346,10 @@
 ) + 
-RANDOM.nextLong() * range
+1)
 ;%0A%0A 

Fix generating integers