//import org.apache.commons.beanutils.BeanUtils;
public static <T> T decode(Class<T> clazz , Map<String,String> msg){
try {
T cls = clazz.newInstance();
Set<Map.Entry<String, String>> entrySet = msg.entrySet();
for(Map.Entry<String,String> entry : entrySet){
BeanUtils.setProperty(cls,entry.getKey(),entry.getValue());
}
return cls;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
将 Map 映射到 类(Map转对象)
最新推荐文章于 2025-04-22 18:13:09 发布