public <V> Map<String, V> convertMap(Map<String, V> valueMap) { Map<String, V> resultMap = new HashMap<String, V>(valueMap.size() * 2 + 1); for (Map.Entry<String, V> entry : valueMap.entrySet()) { String path = entry.getKey(); V value = entry.getValue(); Set<String> mappedPaths = getMappedPaths(path); for (String mappedPath : mappedPaths) { resultMap.put(mappedPath, value); } } return resultMap; } }
public <V> Map<String, V> convertMap(Map<String, V> valueMap) { Map<String, V> resultMap = new HashMap<String, V>(valueMap.size() * 2 + 1); for (Map.Entry<String, V> entry : valueMap.entrySet()) { String path = entry.getKey(); V value = entry.getValue(); Set<String> mappedPaths = getMappedPaths(path); for (String mappedPath : mappedPaths) { resultMap.put(mappedPath, value); } } return resultMap; } }
public void testPathMatchesExact() { Set<String> mappedPaths = mapper.getMappedPaths("/a/b/c"); assertEquals("Exact matches expected", 2, mappedPaths.size()); mappedPaths = mapper.getMappedPaths("/a"); assertEquals("Exact match NOT expected", 0, mappedPaths.size()); }