| | |
| | | package com.consum.base.core.utils; |
| | | |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | @Slf4j |
| | | public class MapUtils { |
| | |
| | | T obj = clazz.newInstance(); |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | Field field = clazz.getDeclaredField(entry.getKey()); |
| | | field.setAccessible(true); |
| | | field.set(obj, entry.getValue()); |
| | | // field.setAccessible(true); |
| | | // field.set(obj, entry.getValue()); |
| | | ReflectUtil.setFieldValue(obj, field, entry.getValue()); |
| | | } |
| | | return obj; |
| | | } catch (InstantiationException | IllegalAccessException | NoSuchFieldException e) { |
| | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |