package com.tourism.common.additional.utils;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class MapConvertUtils {

    public static Map<String, Object> convertObjectToMap(Object obj) {

        Field[] declaredFields = obj.getClass().getDeclaredFields();
        Map<String, Object> tourismFileMap = new HashMap<>();
        Arrays.stream(declaredFields).forEach(field -> {
            field.setAccessible(true);
            try {
                tourismFileMap.put(field.getName(), field.get(obj));
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        });
        return tourismFileMap;
    }
}
