vo,po对象属性转成map
public Map<String,Object> convertThis2Map() {
Map<String,Object> map = new HashMap<String,Object>();
Field[] fields = this.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
String filedName = fields[i].getName();
if("serialVersionUID".equals(filedName)){
continue;
}
StringBuilder sb = new StringBuilder("get");
sb.append(filedName.substring(0, 1).toUpperCase());
sb.append(filedName.substring(1, filedName.length()));
try {
Method method = this.getClass().getMethod(sb.toString());
Object object = method.invoke(this);
if(object != null){
map.put(filedName, object);
}
} catch (Exception e) {
e.printStackTrace();
}
}
map.put("MAX_SIZE", MAX_SIZE);
return map;
}