aboutsummaryrefslogtreecommitdiff
path: root/src/ch/epfl/xblast/ArgumentChecker.java
blob: 8e7ba762eaf8bfac300451769a0753ffd3c4b584 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package ch.epfl.xblast;

/**
 * ArgumentChecker.
 *
 * @author Timothée FLOURE (257420)
 */
public final class ArgumentChecker {
    /**
     * Return the given value if it is non-negative
     *
     * @param value the tested value
     * @throws IllegalArgumentException if the value is inferior to 0
     * @return the given value if non-negative
     */
    public static int requireNonNegative(int value) {
        if (value >= 0) {
            return value;
        } else {
            throw new IllegalArgumentException();
        }
    }
}