Java Assert Not Null assertNotNull(String variableName, Object value)

Here you can find the source of assertNotNull(String variableName, Object value)

Description

Method throws NullPointerException when the variable named variableName has a null value.

License

LGPL

Return

The value.

Declaration

public static Object assertNotNull(String variableName, Object value) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**//  www.j a  v a  2 s.co m
     * Method throws NullPointerException when the variable named variableName has a null value.
     *
     * @return The value.
     */
    public static Object assertNotNull(String variableName, Object value) {

        if (value == null)
            throw new NullPointerException("The variable named " + variableName + " is null.");

        return value;
    }
}

Related

  1. assertNotNull(Object... params)
  2. assertNotNull(String errorMessage, Object... args)
  3. assertNotNull(String fieldName, Object object)
  4. assertNotNull(String message, Object object)
  5. assertNotNull(String message, Object val)
  6. assertNotNull(StringBuilder buffer)
  7. assertNotNull(T exception, Object... objects)
  8. assertNotNull(T o)
  9. assertNotNull(T obj)