解析实体对象将信息转为map

发布时间 2023-05-31 23:55:12作者: 丿sky-
 1 public static HashMap<String,Object> getRetuMap(Object retu) throws IllegalArgumentException, IllegalAccessException {
 2     HashMap<String,Object> map = new HashMap<String,Object>();
 3     Field[] fields=retu.getClass().getDeclaredFields();
 4     for ( Field field : fields ){
 5         if(field.getName().equals("typeDesc")||
 6          field.getName().equals("__equalsCalc")
 7         ||field.getName().equals("__hashCodeCalc")) {
 8             continue;
 9         }
10         field.setAccessible(true);
11         map.put(field.getName(), field.get(retu));
12     }
13     return map;
14 }