Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** * Check if the object has a class to avoid * @param object Object to check * @param avoidClasses Class[] list of classes to avoid * @return boolean TRUE if the class is in the list, FALSE to continue */ private static boolean isObjectToAvoid(Object object, Class[] avoidClasses) { if (object != null && avoidClasses != null) { Class objectClass = object.getClass(); do { for (Class klass : avoidClasses) { if (objectClass.equals(klass)) { return true; } } objectClass = objectClass.getSuperclass(); } while (objectClass != null); } //not found return false; } }