View Javadoc

1   package org.kuali.common.util;
2   
3   public class ReflectionUtils extends org.springframework.util.ReflectionUtils {
4   
5   	public static Class<?> getClass(String className) {
6   		try {
7   			return Class.forName(className);
8   		} catch (ClassNotFoundException e) {
9   			throw new IllegalArgumentException(e);
10  		}
11  	}
12  
13  	public static <T> T newInstance(String className) {
14  		@SuppressWarnings("unchecked")
15  		Class<T> clazz = (Class<T>) getClass(className);
16  		return (T) newInstance(clazz);
17  	}
18  
19  	public static <T> T newInstance(Class<T> instanceClass) {
20  		try {
21  			return (T) instanceClass.newInstance();
22  		} catch (IllegalAccessException e) {
23  			throw new IllegalArgumentException("Unexpected error", e);
24  		} catch (InstantiationException e) {
25  			throw new IllegalArgumentException("Unexpected error", e);
26  		}
27  	}
28  
29  }