package com.rollbar.payload.utilities;

/**
 * Validates arguments.
 */
public class Validate {
    public static void isNotNullOrWhitespace(String x, String name) throws ArgumentNullException {
        if (x == null || x.trim().isEmpty()) {
            throw new ArgumentNullException(name);
        }
    }

    public static void maxLength(String x, int max, String name) throws InvalidLengthException {
        if (x.length() > max) {
            throw InvalidLengthException.TooLong(name, max);
        }
    }

    public static <T> void minLength(T[] x, int min, String name) throws InvalidLengthException {
        if (x.length < min) {
            throw InvalidLengthException.TooShort(name, min);
        }
    }

    public static <T> void isNotNull(T data, String name) throws ArgumentNullException {
        if (data == null) {
            throw new ArgumentNullException(name);
        }
    }
}

@@ -64,664 +64,1844 @@
 nts.
-%0A */%0Apublic class Validate %7B%0A    public static void isNotNullOrWhitespace(String x, String name) throws ArgumentNullException %7B%0A        if (x == null %7C%7C x.trim().isEmpty()) %7B%0A            throw new ArgumentNullException(name);%0A        %7D%0A    %7D%0A%0A    public static void maxLength(String x, int max, String name) throws InvalidLengthException %7B%0A        if (x.length() %3E max) %7B%0A            throw InvalidLengthException.TooLong(name, max);%0A        %7D%0A    %7D%0A%0A    public static %3CT%3E void minLength(T%5B%5D x, int min, String name) throws InvalidLengthException %7B%0A        if (x.length %3C min) %7B%0A            throw InvalidLengthException.TooShort(name, min);%0A        %7D%0A    %7D%0A
+ Throws runtime exceptions when the validation fails.%0A */%0Apublic class Validate %7B%0A    /**%0A     * Asserts that the String is not null or purely whitespace.%0A     * @param x the string to validate%0A     * @param name the name of the argument that's being tested.%0A     * @throws ArgumentNullException if %7B@code x%7D is null or whitespace.%0A     */%0A    public static void isNotNullOrWhitespace(String x, String name) throws ArgumentNullException %7B%0A        if (x == null %7C%7C x.trim().isEmpty()) %7B%0A            throw new ArgumentNullException(name);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Asserts that the String is not longer than %7B@code max%7D.%0A     * @param x The string to test%0A     * @param max the maximum length%0A     * @param name the name of the argument that's being tested.%0A     * @throws InvalidLengthException if %7B@code x%7D is longer than %7B@code max%7D%0A     */%0A    public static void maxLength(String x, int max, String name) throws InvalidLengthException %7B%0A        if (x.length() %3E max) %7B%0A            throw InvalidLengthException.TooLong(name, max);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Asserts that the String is not shorter than %7B@code max%7D.%0A     * @param x The string to test%0A     * @param min the minimum length%0A     * @param name the name of the argument that's being tested.%0A     * @throws InvalidLengthException if %7B@code x%7D is shorter than %7B@code max%7D%0A     */%0A    public static %3CT%3E void minLength(T%5B%5D x, int min, String name) throws InvalidLengthException %7B%0A        if (x.length %3C min) %7B%0A            throw InvalidLengthException.TooShort(name, min);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Asserts that the argument is not null.%0A     * @param data the object to test%0A     * @param name the name of the argument that's being tested%0A     * @param %3CT%3E the type of the object being tested%0A     * @throws ArgumentNullException if %7B@code data%7D is null%0A     */
 %0A   

Document Validate