1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.util;
17
18 import org.kuali.rice.krad.bo.ExternalizableBusinessObject;
19
20
21
22
23 public final class ExternalizableBusinessObjectUtils {
24 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ExternalizableBusinessObjectUtils.class);
25
26 private ExternalizableBusinessObjectUtils() {
27 throw new UnsupportedOperationException("do not call");
28 }
29
30
31
32
33
34
35
36 public static Class determineExternalizableBusinessObjectSubInterface(Class businessObjectClass) {
37 if (businessObjectClass == null) {
38 return null;
39 }
40
41 if (!ExternalizableBusinessObject.class.equals(businessObjectClass) && ExternalizableBusinessObject.class.isAssignableFrom(businessObjectClass)) {
42 return businessObjectClass;
43 }
44 if (ExternalizableBusinessObject.class.isAssignableFrom(businessObjectClass)) {
45 Class tempClass = businessObjectClass;
46 while (tempClass != null && !Object.class.equals(tempClass)) {
47 for (Class tempClassInterface : tempClass.getInterfaces()) {
48 if (!ExternalizableBusinessObject.class.equals(tempClassInterface) && ExternalizableBusinessObject.class.isAssignableFrom(tempClassInterface)) {
49 return tempClassInterface;
50 }
51 }
52 tempClass = tempClass.getSuperclass();
53 }
54 }
55 return null;
56 }
57
58 public static boolean isExternalizableBusinessObjectInterface(Class businessObjectClass) {
59 return businessObjectClass != null && businessObjectClass.isInterface() && ExternalizableBusinessObject.class.isAssignableFrom(businessObjectClass);
60 }
61
62 public static boolean isExternalizableBusinessObjectInterface(String businessObjectClassName) {
63 try {
64 Class businessObjectClass = Class.forName( businessObjectClassName );
65 return isExternalizableBusinessObjectInterface(businessObjectClass);
66 } catch ( Exception ex ) {
67 LOG.debug( "Unable to get class object for class name: " + businessObjectClassName, ex );
68 return false;
69 }
70 }
71 }