ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Map强制警告处理

2022-05-25 09:33:16  阅读:29  来源: 互联网

标签:Map typeConversionMap obj HashMap result entry 强制 警告


    public <K, V> Map<K, V> typeConversionMap(Object obj, Class<K> tClass, Class<V> vClass) {
        HashMap<K, V> result = new HashMap<>();
        if (obj instanceof Map<?, ?>) {
            Map<?, ?> map = (Map<?, ?>) (obj);
            for (Map.Entry<?, ?> entry : map.entrySet()) {
                result.put(tClass.cast(entry.getKey()), vClass.cast(entry.getValue()));
            }
        }
        return result;
    }


Map<String, Object> restParamsMap = typeConversionMap(attributeObject,String.class,Object.class);

 

标签:Map,typeConversionMap,obj,HashMap,result,entry,强制,警告
来源: https://www.cnblogs.com/live365wang/p/16308074.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有