MapToBeanConvertor { public <T> T toBean(Map<String, ?> propValues, Class<T> beanClass){ Assert.notNull(beanClass); Assert.notNull(propValues); T bean = ReflectUtils.newInstance(beanClass); return injectBeanProperties(propValues, bean); }  final static MapToBeanConvertor inst(); T toBean(Map<String, ?> propValues, Class<T> beanClass); @SuppressWarnings("unchecked") T injectBeanProperties(Map<String, ?> propValues, T bean); void setKeyConvertor(Function<PropertyContext, String> keyConvertor);  }
@Test public void test() { Date birthDay = DateUtils.parse("2019-04-25"); Map<String, ?> map = CUtils.asMap("id", 123, "user_name", "testUserName", "birthDay", birthDay, "roles[0].id", 222, "roles[0].name", "testRoleName" ); MapToBeanConvertor map2Bean = MapToBeanConvertor.builder().build(); UserEntity user = map2Bean.toBean(map, UserEntity.class); assertThat(user).isNotNull(); assertThat(user.getId()).isEqualTo(123); assertThat(user.getUserName()).isNull(); assertThat(user.getBirthDay()).isEqualTo(birthDay); assertThat(user.getRoles()).isNull(); }