001package org.junit.internal;
002
003/** @since 4.13 */
004public final class Checks {
005
006    private Checks() {}
007
008    /**
009     * Checks that the given value is not {@code null}.
010     *
011     * @param value object reference to check
012     * @return the passed-in value, if not {@code null}
013     * @throws NullPointerException if {@code value} is {@code null}
014     */
015    public static <T> T notNull(T value) {
016        if (value == null) {
017            throw new NullPointerException();
018        }
019        return value;
020    }
021
022    /**
023     * Checks that the given value is not {@code null}, using the given message
024     * as the exception message if an exception is thrown.
025     *
026     * @param value object reference to check
027     * @param message message to use if {@code value} is {@code null}
028     * @return the passed-in value, if not {@code null}
029     * @throws NullPointerException if {@code value} is {@code null}
030     */
031    public static <T> T notNull(T value, String message) {
032        if (value == null) {
033            throw new NullPointerException(message);
034        }
035        return value;
036    }
037}