Java Assert Not Null assertNotNull(Object obj, String name)

Here you can find the source of assertNotNull(Object obj, String name)

Description

Checks whether the given Object is not null.

License

Open Source License

Parameter

Parameter Description
obj the argument to check
name the name of the argument

Exception

Parameter Description
IllegalArgumentException if the given Object(obj) is null

Declaration

public static void assertNotNull(Object obj, String name) 

Method Source Code

//package com.java2s;

public class Main {
    /**// ww  w  . j  a  va  2s.  c o m
     * <p>
     * Checks whether the given Object is not null.
     * </p>
     *
     * @param obj the argument to check
     * @param name the name of the argument
     * @throws IllegalArgumentException if the given Object(obj) is null
     */
    public static void assertNotNull(Object obj, String name) {
        if (obj == null) {
            throw new IllegalArgumentException("[ " + name
                    + " ] should not be null.");
        }
    }
}

Related

  1. assertNotNull(Object o)
  2. assertNotNull(Object obj)
  3. assertNotNull(Object obj)
  4. assertNotNull(Object obj, RuntimeException ex)
  5. assertNotNull(Object obj, String msgTemplate, Object... params)
  6. assertNotNull(Object obj, String name)
  7. assertNotNull(Object object)
  8. assertNotNull(Object object, RuntimeException cause)
  9. assertNotNull(Object object, String description)