Java Assert Not Null assertParameterNotNull(Object parameterValue, String errorMessage)

Here you can find the source of assertParameterNotNull(Object parameterValue, String errorMessage)

Description

Asserts that the specified parameter value is not null and if it is, throws an IllegalArgumentException with the specified error message.

License

Amazon Software License

Parameter

Parameter Description
parameterValue The parameter value being checked.
errorMessage The error message to include in the IllegalArgumentException if the specified parameter is null.

Declaration

public static void assertParameterNotNull(Object parameterValue, String errorMessage) 

Method Source Code

//package com.java2s;
//License from project: Amazon Software License 

public class Main {
    /**/* w w  w  . j av  a 2  s . co  m*/
     * <p>
     * Asserts that the specified parameter value is not <code>null</code> and
     * if it is, throws an <code>IllegalArgumentException</code> with the
     * specified error message.
     * </p>
     *
     * @param parameterValue The parameter value being checked.
     * @param errorMessage The error message to include in the
     *            IllegalArgumentException if the specified parameter is null.
     */
    public static void assertParameterNotNull(Object parameterValue, String errorMessage) {
        if (parameterValue == null) {
            throw new IllegalArgumentException(errorMessage);
        }
    }
}

Related

  1. assertNotNullOrThrowException(final Object... objects)
  2. assertObjectNotNull(final Object object)
  3. assertObjectNotNull(Object o, String name)
  4. assertObjectNotNull(String variableName, Object value)
  5. assertObjectNotNull(String variableName, Object value)
  6. assertParamNotNull(Object check, String paramName)
  7. assertParamNotNull(String param, String paramName)
  8. assertPatternNotNull(String methodName, String pattern)
  9. assertResourceNotNull(String resourcePath, Object resourceHandle)