返回min-max间的随机Long,可传入SecureRandom或ThreadLocalRandom.

min必须大于0.

JDK本身不具有控制两端范围的nextLong，因此参考Commons Lang RandomUtils的实现, 不直接复用是因为要传入Random实例

@see org.apache.commons.lang3.RandomUtils#nextLong(long, long)
540349
public static long nextLong(Random random, long min, long max) {
		Validate.isTrue(max >= min, "Start value must be smaller or equal to end value.");
		MoreValidate.nonNegative("min", min);

		if (min == max) {
			return min;
		}

		return (long) (min + ((max - min) * random.nextDouble()));
	}
1070290
public void randomWait(long min, long max) {
		final long waitTime = randomLong(min, max);
		try {
			Thread.sleep(waitTime);
		} catch (InterruptedException interruptedException) {
			// ignored
		}
	}
1089749
public String getRandomText(final int minLength, final int maxLength) {
    validateMinMaxParams(minLength, maxLength);

    StringBuilder sb = new StringBuilder(maxLength);
    int length = minLength;
    if (maxLength != minLength) {
      length = length + random.nextInt(maxLength - minLength);
    }
    while (length > 0) {
      if (sb.length() != 0) {
        sb.append(" ");
        length--;
      }
      final double desiredWordLengthNormalDistributed = 1.0 + Math.abs(random.nextGaussian()) * 6;
      int usedWordLength = (int) (Math.min(length, desiredWordLengthNormalDistributed));
      String word = getRandomWord(usedWordLength);
      sb.append(word);
      length = length - word.length();
    }
    return sb.toString();

  }
466913
@SuppressWarnings("NumericOverflow")
    private static long nextLong(long n) {
        long bits, val;
        do {
            bits = ThreadLocalRandom.current().nextLong() & (~(1L << BITS_PER_LONG));
            val = bits % n;
        } while (bits - val + (n - 1) < 0L);
        return val;
    }
841961
public static long firstLong(PreparedStatement stmt) throws SQLException {
		ResultSet rs = stmt.executeQuery();
		long l = rs.next() ? rs.getLong(1) : Long.MIN_VALUE;
		stmt.close();
		return l;
	}
416248
public static long randomLongLessThan(long maxExclusive) {
    checkArgument(
        maxExclusive > Long.MIN_VALUE, "Cannot produce long less than %s", Long.MIN_VALUE);
    return randomLong(Long.MIN_VALUE, maxExclusive);
  }
868670
public static String getRandomNumber(int numberLength, boolean paddingOn) {
        if (numberLength < 1) {
            throw new InvalidFunctionUsageException("numberLength must be greater than 0 - supplied " + numberLength);
        }

        StringBuilder buffer = new StringBuilder();
        for (int i = 0; i < numberLength; i++) {
            buffer.append(generator.nextInt(10));
        }

        return checkLeadingZeros(buffer.toString(), paddingOn);
    }
1108613
public static StringRandomizer aNewStringRandomizer(final Charset charset, final int maxLength, final long seed) {
        return new StringRandomizer(charset, maxLength, seed);
    }
677964
long string2Long(CharSequence cs, int readed) {
		if (cs.length() > 16) {
			throw new JsonParseException("Number string is too long.", readed);
		}
		long n = 0;
		for (int i = 0; i < cs.length(); i++) {
			n = n * 10 + (cs.charAt(i) - '0');
			if (n > MAX_SAFE_INTEGER) {
				throw new JsonParseException("Exceeded maximum value: "
						+ MAX_SAFE_INTEGER, readed);
			}
		}
		return n;
	}
372673
protected void validateLong(int index, long min, long max, String errorKey, String errorMessage) {
		String value = controller.getPara(index);
		if (value != null && (value.startsWith("N") || value.startsWith("n"))) {
			value = "-" + value.substring(1);
		}
		validateLongValue(value, min, max, errorKey, errorMessage);
	}
576390
public EasyRandomParameters stringLengthRange(final int minStringLength, final int maxStringLength) {
        if (minStringLength < 0) {
            throw new IllegalArgumentException("minStringLength must be >= 0");
        }
        if (minStringLength > maxStringLength) {
            throw new IllegalArgumentException(format("minStringLength (%s) must be <= than maxStringLength (%s)",
                    minStringLength, maxStringLength));
        }
        setStringLengthRange(new Range<>(minStringLength, maxStringLength));
        return this;
    }
1180748
public final long nextLong(final long n)
        {
        if (n<=0)
            throw new IllegalArgumentException("n must be > 0");
        
        long bits, val;
        do 
            {
            int y;
            int z;
    
            if (mti >= N)   // generate N words at one time
                {
                int kk;
                @SuppressWarnings("hiding")
				final int[] mt = this.mt; // locals are slightly faster 
                @SuppressWarnings("hiding")
				final int[] mag01 = this.mag01; // locals are slightly faster 
            
                for (kk = 0; kk < N - M; kk++)
                    {
                    y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
                    mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1];
                    }
                for (; kk < N-1; kk++)
                    {
                    y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
                    mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1];
                    }
                y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK);
                mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1];
    
                mti = 0;
                }
    
            y = mt[mti++];
            y ^= y >>> 11;                          // TEMPERING_SHIFT_U(y)
            y ^= (y << 7) & TEMPERING_MASK_B;       // TEMPERING_SHIFT_S(y)
            y ^= (y << 15) & TEMPERING_MASK_C;      // TEMPERING_SHIFT_T(y)
            y ^= (y >>> 18);                        // TEMPERING_SHIFT_L(y)
    
            if (mti >= N)   // generate N words at one time
                {
                int kk;
                @SuppressWarnings("hiding")
				final int[] mt = this.mt; // locals are slightly faster 
                @SuppressWarnings("hiding")
				final int[] mag01 = this.mag01; // locals are slightly faster 
                
                for (kk = 0; kk < N - M; kk++)
                    {
                    z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
                    mt[kk] = mt[kk+M] ^ (z >>> 1) ^ mag01[z & 0x1];
                    }
                for (; kk < N-1; kk++)
                    {
                    z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
                    mt[kk] = mt[kk+(M-N)] ^ (z >>> 1) ^ mag01[z & 0x1];
                    }
                z = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK);
                mt[N-1] = mt[M-1] ^ (z >>> 1) ^ mag01[z & 0x1];
                
                mti = 0;
                }
            
            z = mt[mti++];
            z ^= z >>> 11;                          // TEMPERING_SHIFT_U(z)
            z ^= (z << 7) & TEMPERING_MASK_B;       // TEMPERING_SHIFT_S(z)
            z ^= (z << 15) & TEMPERING_MASK_C;      // TEMPERING_SHIFT_T(z)
            z ^= (z >>> 18);                        // TEMPERING_SHIFT_L(z)
            
            bits = (((((long)y) << 32) + z) >>> 1);
            val = bits % n;
            } while (bits - val + (n-1) < 0);
        return val;
        }
1300159
public static int randomIntLessThan(int maxExclusive) {
    checkArgument(
        maxExclusive > Integer.MIN_VALUE, "Cannot produce int less than %s", Integer.MIN_VALUE);
    return randomInt(Integer.MIN_VALUE, maxExclusive);
  }
817804
public synchronized long exponentialWait() {
        long maxDelayRet = minDelay + ((maxDelay - minDelay) / maxFailureCount) * currentFailureCount;
        return (long) (random.nextFloat() * maxDelayRet);
    }
959237
public static int random(final int min, final int max) {
        return min + new java.security.SecureRandom().nextInt(max - min + 1);
    }
1208270
public static int random(int min, int max) {
        if (min < 0 || max < 0) {
            throw new RuntimeException(
                    "illegal argment, min and max must great then zero.");
        }
        if (min > max) {
            int t = max;
            max = min;
            min = t;
        } else if (min == max) {
            return min;
        }

        Random random = new Random();
        return random.nextInt(max) % (max - min + 1) + min;

    }
329411
public static String ENDPOINT_MAX_MESSAGE_SIZE_TOO_LONG(Object arg0, Object arg1, Object arg2, Object arg3) {
        return localizer.localize(localizableENDPOINT_MAX_MESSAGE_SIZE_TOO_LONG(arg0, arg1, arg2, arg3));
    }