Here you can find the source of assertInstance(Object object, Class c)
public static void assertInstance(Object object, Class c)
//package com.java2s; /******************************************************************************* * Copyright (c) 2003, 2005 IBM Corporation 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://from ww w .j a v a 2s .co m * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { public static void assertInstance(Object object, Class c) { assertInstance(object, c, false); } public static void assertInstance(Object object, Class c, boolean allowNull) { if (object == null && allowNull) return; if (object == null || c == null) throw new NullPointerException(); else if (!c.isInstance(object)) throw new IllegalArgumentException(); } }