BaseEntity implements Cloneable, Serializable { public Map<String, Object> beanToMap() { final Map<String, Object> beanToMap = Maps.newHashMap(); for (String key : attributeNames()) { final Object value = attributeValue(key); if (value != null) { beanToMap.put(key, value); } } return beanToMap; }  String[] attributeNames(); @SuppressWarnings("unchecked") T attributeValue(final String fieldName); T attributeValue(final String fieldName, final T defaultValue); void setAttributeValue(final String fieldName, final Object value); void setAttributeValue(final String fieldName, final Object value, final boolean isCase); Map<String, Object> beanToMap(); static T mapToBean(Map<String, Object> beanMap, Class<T> beanType); static List<T> mapToBeans(final List<Map<String, Object>> beanMaps, final Class<T> beanType); static Map<String, Method> paramMethods(Class<?> cls); static Map<String, Field> paramFields(Class<?> cls); Collection<Method> methods(); Collection<Field> fields(); @Override BaseEntity clone(); @Override String toString();  }
@Test public void getBeanToMapTest() { UseEntity entity = new UseEntity(); entity.setId("id0"); entity.setName("name0"); Map<String, Object> map = entity.beanToMap(); assertNotNull(map); assertEquals("id0", map.get("id")); assertEquals("name0", map.get("name")); }