1 23 24 package com.rift.coad.lib.common; 25 26 import com.rift.coad.lib.common.*; 27 28 33 public class ClassUtil { 34 35 38 private ClassUtil() { 39 } 40 41 49 public static boolean testForParent(Class ref, Class parentName) { 50 return testForParent(ref, parentName.getName()); 51 } 52 53 61 public static boolean testForParent(Class ref, String parentName) { 62 if (ref == null) { 63 return false; 64 } else if (ref.getName().equals(parentName)) { 65 return true; 66 } else if (ref.getName().equals(java.lang.Object .class.getName())) { 67 return false; 68 } 69 Class [] interfaces = ref.getInterfaces(); 70 for (int index = 0; index < interfaces.length; index++) { 71 if (testForParent(interfaces[index],parentName)) { 72 return true; 73 } 74 } 75 return testForParent(ref.getSuperclass(),parentName); 76 } 77 } 78 | Popular Tags |