public static boolean isInstanceOf ( Object obj , String classSimpleName ) { if ( obj == null ) { return false ; } Class < ? > currentClass = obj . getClass ( ) ; while ( currentClass != Object . class ) { if ( currentClass . getSimpleName ( ) . equals ( classSimpleName ) ) { return true ; } else { currentClass = currentClass . getSuperclass ( ) ; } } return false ; }
Check whether an object is an instance of a specified class .