package com.reyun.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Map;

/**
 * Created by nolan on 16/9/28.
 * description:
 */
public class BeanUtils {

    public static Map bean2Map(Object obj) {
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.convertValue(obj, Map.class);
    }

    public static <T> T map2Bean(Map fromValue, Class<T> toValueType) throws IllegalArgumentException {
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.convertValue(fromValue, toValueType);
    }
}
