Java Assert Not Null assertNotNull(Object object, RuntimeException cause)

Here you can find the source of assertNotNull(Object object, RuntimeException cause)

Description

assert Not Null

License

Open Source License

Declaration

public static void assertNotNull(Object object, RuntimeException cause) 

Method Source Code

//package com.java2s;
/**//  w ww  .j  a v a2  s . c o m
 *   27/giu/2011
 *
 * Copyright (c) 2010 Alten Italia, All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Alten Italia ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use it
 * only in accordance with the terms of the license agreement you entered 
 * into with Alten Italia.
 *
 * Alten Italia - MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY 
 * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 
 * OR NON-INFRINGEMENT. ALTEN ITALIA SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED
 * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR 
 * ITS DERIVATIVES.
 */

public class Main {
    /**
     * Solleva una @link(IllegalArgumentException) con message message in caso di object null
     * 
     * @param object
     * @param message
     */
    public static void assertNotNull(Object object, String message) {
        if (object == null) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void assertNotNull(Object object, RuntimeException cause) {
        if (object == null) {
            cause.initCause(cause.getCause());
            throw cause;
        }
    }
}

Related

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