public static Object convertMap2Bean(Class type, Map map)
throws IntrospectionException, IllegalAccessException,
InstantiationException, InvocationTargetException {
BeanInfo beanInfo = Introspector.getBeanInfo(type);
Object obj = type.newInstance();
PropertyDescriptor[] propertyDescriptors = beanInfo
.getPropertyDescriptors();
for (PropertyDescriptor pro : propertyDescriptors) {
String propertyName = pro.getName();
if (pro.getPropertyType().getName().equals("java.lang.Class")) {
continue;
}
if (map.containsKey(propertyName)) {
Object value = map.get(propertyName);
Method setter = pro.getWriteMethod();
setter.invoke(obj, value);
}
}
return obj;
}
BeanMapUtil.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:zooadmin
作者:
评论列表
文章目录