属性描述符相关 转载 https://www.cnblogs.com/tony-yang-flutter/p/3485690.html public static <T> Map<String, Object> toMap(T t) { HashMap map = new HashMap(); try { BeanInfo beanInfo = Introspector.getBeanInfo(t.getClass()); if (beanInfo == null) { return map; } PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); if (propertyDescriptors == null || propertyDescriptors.length == 0) { return map; } PropertyDescriptor[] var4 = propertyDescriptors; int var5 = propertyDescriptors.length; for(int var6 = 0; var6 < var5; ++var6) { PropertyDescriptor property = var4[var6]; String key = property.getName(); if (!key.equals("class")) { Method getter = property.getReadMethod(); Object value = getter.invoke(t); map.put(key, value); } } } catch (Exception var11) { var11.printStackTrace(); } return map; }