Java Assert Null assertIsNull(Object obj)

Here you can find the source of assertIsNull(Object obj)

Description

Asserts that the passed entry is null

License

Open Source License

Declaration

public static void assertIsNull(Object obj) 

Method Source Code

//package com.java2s;
/**/*w  w  w .j a  v  a2  s .c o  m*/
 * <copyright>
 *
 * Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Martin Taal - Initial API and implementation
 *
 * </copyright>
 *
 * $Id: AssertUtil.java,v 1.7 2009/03/30 07:53:04 mtaal Exp $
 */

public class Main {
    /** Asserts that the passed entry is null */
    public static void assertIsNull(Object obj) {
        if (obj != null) {
            throw new AssertionError("Passed object: "
                    + obj.getClass().getName()
                    + " is not null while this was expected");
        }
    }
}

Related

  1. assertAllAreNull(String messageIfNull, Object... objects)
  2. assertInstance(final Object object, final Class c, final boolean allowNull)
  3. assertNonNull(final T object, final String paramName)
  4. assertNonNull(String argumentName, Object argument)
  5. assertNoNull(Object object, String paramName)
  6. assertNull(final Object obj, final String msg)