public static Object mapToObject(Map<String, String> map, Class<?> clazz) {
        if (CollectionUtils.isEmpty(map)) {
            return null;
        }
        try {
            Object instance = clazz.newInstance();
            Field[] fields = instance.getClass().getDeclaredFields();
            for (Field field : fields) {
                int modifiers = field.getModifiers();
                if (Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers)) {
                    continue;
                }
                boolean accessible = field.isAccessible();
                field.setAccessible(true);
                Class<?> type = field.getType();
                if (type == Date.class) {
                    if (!StringUtils.isEmpty(map.get(field.getName()))) {
                        field.set(instance, new Date(Long.valueOf(map.get(field.getName()))));
                    }
                } else if (type == Long.class) {
                    if (!StringUtils.isEmpty(map.get(field.getName()))) {
                        field.set(instance, Long.valueOf(map.get(field.getName())));
                    }
                } else if (type == Integer.class) {
                    if (!StringUtils.isEmpty(map.get(field.getName()))) {
                        field.set(instance, Integer.valueOf(map.get(field.getName())));
                    }
                } else if (type == Double.class) {
                    if (!StringUtils.isEmpty(map.get(field.getName()))) {
                        field.set(instance, Double.valueOf(map.get(field.getName())));
                    }
                } else if (type == String.class) {
                    if (!StringUtils.isEmpty(map.get(field.getName()))) {
                        field.set(instance, map.get(field.getName()));
                    }
                }
                field.setAccessible(accessible);
            }
            return instance;
        } catch (IllegalAccessException e) {
            throw new NotSupportYetException(
                    "map to " + clazz.toString() + " failed:" + e.getMessage(), e);
        } catch (InstantiationException e) {
            throw new NotSupportYetException(
                    "map to " + clazz.toString() + " failed:" + e.getMessage(), e);
        }
    }
@Test
    public void testMapToObject() {
        // null map
        BranchDO branchDO =
                (BranchDO) BeanUtils.mapToObject(null, BranchDO.class);
        Assertions.assertNull(branchDO);

        Map<String, String> map = new HashMap<>();
        Date date = new Date();
        map.put("xid", "192.166.166.11:9010:12423424234234");
        map.put("transactionId", "12423424234234");
        map.put("status", "2");
        map.put("test", "22.22");
        map.put("gmtCreate", String.valueOf(date.getTime()));
        map.put("msg", "test");
        map.put("testByte", "1");
        branchDO = (BranchDO) BeanUtils.mapToObject(map, BranchDO.class);
        Assertions.assertEquals(map.get("xid"), branchDO.getXid());
        Assertions.assertEquals(Long.valueOf(map.get("transactionId")), branchDO.getTransactionId());
        Assertions.assertEquals(Integer.valueOf(map.get("status")), branchDO.getStatus());
        Assertions.assertEquals(Double.valueOf(map.get("test")), branchDO.getTest());
        Assertions.assertEquals(new Date(date.getTime()), branchDO.getGmtCreate());

        map = new HashMap<>();
        map.put("xid", null);
        map.put("transactionId", null);
        map.put("status", null);
        map.put("test", null);
        map.put("gmtCreate", null);
        branchDO = (BranchDO) BeanUtils.mapToObject(map, BranchDO.class);
        Assertions.assertNull(branchDO.getXid());
        Assertions.assertNull(branchDO.getTransactionId());
        Assertions.assertNull(branchDO.getStatus());
        Assertions.assertNull(branchDO.getTest());
        Assertions.assertNull(branchDO.getGmtCreate());
        // InstantiationException
        Assertions.assertThrows(NotSupportYetException.class, () -> {
            Map<String, String> map1 = new HashMap<>();
            map1.put("xid", "1");
            BeanUtils.mapToObject(map1, DefaultValues.class);
        });
        // IllegalAccessException
        Assertions.assertThrows(NotSupportYetException.class, () -> {
            Map<String, String> map1 = new HashMap<>();
            map1.put("xid", "1");
            BeanUtils.mapToObject(map1, RpcStatus.class);
        });
    }