Here you can find the source of assertObjectNullOrIsInstance(Object obj, Class expectedType, String name)
Parameter | Description |
---|---|
obj | the given object to check. |
expectedType | the expected class. |
name | the name to identify the object. |
Parameter | Description |
---|---|
IllegalArgumentException | if the given object is null or is not an instance of the expected class. |
static void assertObjectNullOrIsInstance(Object obj, Class expectedType, String name)
//package com.java2s; public class Main { /**//from w ww .j a v a 2 s . co m * Check if the given object is an instance of the expected class. * * @param obj the given object to check. * @param expectedType the expected class. * @param name the name to identify the object. * * @throws IllegalArgumentException if the given object is null or is not an instance of the expected class. */ static void assertObjectNullOrIsInstance(Object obj, Class expectedType, String name) { if (obj != null && !expectedType.isInstance(obj)) { throw new IllegalArgumentException(name + " of type [" + obj.getClass().getName() + "] should be an instance of " + expectedType.getName()); } } }