package com.sunwin.metro.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: data_governance
 * @description: 判断某个值的基本类型
 * @author: xuYJ
 * @create: 2022-02-18 15:14
 **/
public class DataType {
    public static Map<String, String> getType(Object o) {
        Map<String, String> typeInfo = new HashMap<String, String>();
        typeInfo.put("类型", o.getClass().getSimpleName());
        typeInfo.put("描述", "引用类型");
        return typeInfo;
    }

    public static Map<String, String> getType(int i) {
        Map<String, String> typeInfo = new HashMap<String, String>();
        typeInfo.put("类型", "int");
        typeInfo.put("描述", "整形");
        return typeInfo;
    }

    public static Map<String, String> getType(long l) {
        Map<String, String> typeInfo = new HashMap<String, String>();
        typeInfo.put("类型", "long");
        typeInfo.put("描述", "长整型");
        return typeInfo;
    }

    public static Map<String, String> getType(boolean b) {
        Map<String, String> typeInfo = new HashMap<String, String>();
        typeInfo.put("类型", "boolean");
        typeInfo.put("描述", "布尔类型");
        return typeInfo;
    }

    public static Map<String, String> getType(char b) {
        Map<String, String> typeInfo = new HashMap<String, String>();
        typeInfo.put("类型", "char");
        typeInfo.put("描述", "字符");
        return typeInfo;
    }

    public static Map<String, String> getType(float f) {
        Map<String, String> typeInfo = new HashMap<String, String>();
        typeInfo.put("类型", "float");
        typeInfo.put("描述", "单精度浮点型");
        return typeInfo;
    }

    public static Map<String, String> getType(double d) {
        Map<String, String> typeInfo = new HashMap<String, String>();
        typeInfo.put("类型", "double");
        typeInfo.put("描述", "双精度浮点型");
        return typeInfo;
    }

    public static Map<String, String> getType(String s) {
        Map<String, String> typeInfo = new HashMap<String, String>();
        typeInfo.put("类型", "String");
        typeInfo.put("描述", "字符串类型");
        return typeInfo;
    }

    public static void main(String[] args) {

        JSONObject jsonObject = new JSONObject();

        Map<String, String> type = getType(jsonObject.get("1"));
        System.out.println("type = " + type);
    }
}
