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);