您的位置:首页 > 其它

工具类:判断一个类是否是给定类的子类

2012-03-20 10:43 281 查看
public class ClassUtils {/*** Checks if a class is a subclass of a class with the specified name. Used* as an instanceOf without having to load the class, useful when trying to* check for classes that might not be available in the runtime JRE.** @param clazz*            The class to check* @param className*            The class name to look for in the super classes* @return true if the class extends a class by the specified name.*/public static boolean extendsClass(final Class<?> clazz, String className) {Class<?> superClass = clazz.getSuperclass();while (superClass != null) {if (superClass.getName().equals(className)) {return true;}superClass = superClass.getSuperclass();}return false;}}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐