工具类代码:
package vip.rory.dht.common.util;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
/**
* @author zhanghangtian
*/
public class BeanUtil {
@SuppressWarnings("unchecked")
public static <T, K, V> T mapToBean(Map<K, V> map, TypeReference<T> typeReference)
throws IllegalArgumentException, InvocationTargetException, ClassNotFoundException, Exception {
Type type = typeReference.getRawType();
return (T) mapToBean(map, Class.forName(type.getTypeName()));
}
public static <T, K, V> T mapToBean(Map<K, V> map, Class<T> clazz)
throws Exception, IllegalArgument