summaryrefslogtreecommitdiffstats
blob: 09d389dfa4205f75623106b5961d87b8249d912a (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
28
29
30
31
/*  Copyright (c) 2016, Isode Limited, London, England.
 *  All rights reserved.
 *
 *  Acquisition and use of this software and related materials for any
 *  purpose requires a written license agreement from Isode Limited,
 *  or a written license from an organisation licensed by Isode Limited
 *  to grant such a license.
 *
 */
package com.isode.stroke.base;

import java.util.Random;

/**
 * A {@link RandomGenerator} that generates integers with a uniform 
 * distribution (using the java {@link Random} class).
 */
public final class JavaRandomGenerator implements RandomGenerator {

    /**
     * {@link Random} to use to generate the numbers
     */
    private final Random rng = new Random();

    @Override
    public int generateRandomInteger(int max) {
        // Random.nextInt(bound) is exclusive of bound
        return rng.nextInt(max+1);
    }

}