@ArgumentsChecked
	@Throws({ IllegalNullArgumentException.class, IllegalInstanceOfArgumentException.class })
	@SuppressWarnings("unchecked")
	public static <T> T instanceOf(@Nonnull final Class<?> type, @Nonnull final Object obj, @Nullable final String name) {
		Check.notNull(type, "type");
		Check.notNull(obj, "obj");
		if (!type.isInstance(obj)) {
			throw new IllegalInstanceOfArgumentException(name, type, obj.getClass());
		}
		return (T) obj;
	}
@ ArgumentsChecked @ Throws ( { IllegalNullArgumentException . class , IllegalInstanceOfArgumentException . class } ) @ SuppressWarnings ( "unchecked" ) public static < T > T instanceOf ( @ Nonnull final Class < ? > type , @ Nonnull final Object obj , @ Nullable final String name ) { Check . notNull ( type , "type" ) ; Check . notNull ( obj , "obj" ) ; if ( ! type . isInstance ( obj ) ) { throw new IllegalInstanceOfArgumentException ( name , type , obj . getClass ( ) ) ; } return ( T ) obj ; }
Ensures that a passed argument is a member of a specific type.

@param type
class that the given object is a member of
@param obj
the object reference that should be a member of a specific {@code type}
@param name
name of object reference (in source code)
@return the given object cast to type

@throws IllegalInstanceOfArgumentException
if the given argument {@code obj} is not a member of {@code type}