1 package net.sf.josceleton.commons.util;
2
3 import java.util.Random;
4
5
6
7
8 public final class RandomUtil {
9
10 private static final Random R = new Random();
11
12 private RandomUtil() {
13
14 }
15
16
17
18
19 public static int randFromZeroToExclusive(final int exclusiveMax) {
20 return R.nextInt(exclusiveMax);
21 }
22
23
24
25
26
27
28
29
30
31
32
33 public static int generateWithinRange(final int middle, final int deviation) {
34 final int start = middle - deviation;
35 final int randMax = deviation * 2 + 1;
36 final int randValue = RandomUtil.R.nextInt(randMax);
37 return start + randValue;
38 }
39
40 }