com.strider.datadefender.utils.XegerUtils   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 5
c 3
b 0
f 0
dl 0
loc 15
ccs 4
cts 4
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRandomInt(int,int,Random) 0 5 1
1
/**
2
 * Copyright 2009 Wilfred Springer
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 *
16
 * Modified by Armenak Grigoryan
17
 */
18
19
20
21
package com.strider.datadefender.utils;
22
23
import java.util.Random;
24
25
public class XegerUtils {
26
27
    /**
28
     * Generates a random number within the given bounds.
29
     *
30
     * @param min The minimum number (inclusive).
31
     * @param max The maximum number (inclusive).
32
     * @param random The object used as the randomizer.
33
     * @return A random number in the given range.
34
     */
35 1226
    public final static int getRandomInt(final int min, final int max, final Random random) {
36 1226
        final int   dif    = max - min;
37 1226
        final float number = random.nextFloat();    // 0 <= number < 1
38
39 1226
        return min + Math.round(number * dif);
40
    }
41
}
42
43
44
//~ Formatted by Jindent --- http://www.jindent.com
45