其他分享
首页 > 其他分享> > Map强制警告处理

Map强制警告处理

作者:互联网

    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