下面是工具类
package com.ninemax.utils;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.PropertyUtils;
// import org.apache.commons.beanutils.converters.DateConverter;
import org.apache.commons.lang.StringUtils;
/**
*
* 反射的 Utils 函数集合
* 提供访问私有变量, 获取泛型类型 Class, 提取集合中元素属性等 Utils 函数
*
*/
public class ReflectionUtils {
/**
* 将反射时的 "检查异常" 转换为 "运行时异常"
* @return
*/
public static IllegalArgumentException convertToUncheckedException(Exception ex){
if(ex instanceof IllegalAccessException || ex instanceof IllegalArgumentException
|| ex instanceof NoSuchMethodException){
throw new IllegalArgumentException("反射异常", ex);
}else{
throw new IllegalArgumentException(ex);
}
}
/**
* 转换字符串类型到 toType 类型, 或 toType 转为字符串
* @param value: 待转换的字符串
* @param toType: 提供类型信息的 Class, 可以是基本数据类型的包装类或指定格式日期型
* @return
*/
// public static Object convertValue(Object value, Class> toType){
// try {
// DateConverter dc = new DateConverter();
//
//