Java Assert Not Null assertNotNull(final Object object, final String message)

Here you can find the source of assertNotNull(final Object object, final String message)

Description

Check whether the object is null or not.

License

MIT License

Parameter

Parameter Description
object the object to check.
message the message to display if the object is null.

Declaration

public static void assertNotNull(final Object object, final String message) 

Method Source Code

//package com.java2s;
/*//from   w w w  .  ja  v  a 2s. c o  m
 * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

public class Main {
    /**
     * Check whether the object is null or not. If it is, throw an exception and display the message.
     * 
     * @param object the object to check.
     * @param message the message to display if the object is null.
     */
    public static void assertNotNull(final Object object, final String message) {
        if (object == null) {
            throw new IllegalArgumentException(message);
        }
    }
}

Related

  1. assertFormatResultNotNull(Object r)
  2. assertInstanceOfNotNull(Object obj, Class expClass)
  3. assertNotNull(final Object o, final String message)
  4. assertNotNull(final Object obj, final String msg)
  5. assertNotNull(final Object obj, final String reference)
  6. assertNotNull(final Object object, final String message)
  7. assertNotNull(final Object param, final String name)
  8. assertNotNull(final Object value, final String name)
  9. assertNotNull(final Object... objects)