@Test(groups = "unit") public void decomposeList() throws Exception { Map<Path,Object> structures = new HashMap<Path,Object>(); structures.put(DefaultPath.fromStrings("list"), Arrays.asList("java.util.ArrayList", Arrays.asList("x", "y", "z"))); Map<Path,Object> expected = new HashMap<Path,Object>(); expected.put(DefaultPath.fromEncodedPathString("list/@0"), "x"); expected.put(DefaultPath.fromEncodedPathString("list/@1"), "y"); expected.put(DefaultPath.fromEncodedPathString("list/@2"), "z"); expected.put(DefaultPath.fromEncodedPathString("list/@3"), "\uFFFF\uFFFF"); Map<Path,Object> result = decomposer.decompose(structures); assertEquals(result, expected); }
public Map<Path,Object> decompose(Map<Path,Object> structures) { if (structures == null) { throw new IllegalArgumentException("structures is null"); } Map<Path,Object> decomposed = new HashMap<Path,Object>(structures.size()); for (Map.Entry<Path,Object> entry : structures.entrySet()) { Object structure = entry.getValue(); Path path = entry.getKey(); if (structure == null) { decomposed.put(path, NULL); continue; } if (Types.isSimple(structure)) { decomposed.put(path, structure); continue; } Map<Path,Object> decomposedMap = decomposeStructure(structure); for (Map.Entry<Path,Object> decomposedEntry : decomposedMap.entrySet()) { decomposed.put(path.concat(decomposedEntry.getKey()), decomposedEntry.getValue()); } } return decomposed; }
Decomposer { public Map<Path,Object> decompose(Map<Path,Object> structures) { if (structures == null) { throw new IllegalArgumentException("structures is null"); } Map<Path,Object> decomposed = new HashMap<Path,Object>(structures.size()); for (Map.Entry<Path,Object> entry : structures.entrySet()) { Object structure = entry.getValue(); Path path = entry.getKey(); if (structure == null) { decomposed.put(path, NULL); continue; } if (Types.isSimple(structure)) { decomposed.put(path, structure); continue; } Map<Path,Object> decomposedMap = decomposeStructure(structure); for (Map.Entry<Path,Object> decomposedEntry : decomposedMap.entrySet()) { decomposed.put(path.concat(decomposedEntry.getKey()), decomposedEntry.getValue()); } } return decomposed; } }
Decomposer { public Map<Path,Object> decompose(Map<Path,Object> structures) { if (structures == null) { throw new IllegalArgumentException("structures is null"); } Map<Path,Object> decomposed = new HashMap<Path,Object>(structures.size()); for (Map.Entry<Path,Object> entry : structures.entrySet()) { Object structure = entry.getValue(); Path path = entry.getKey(); if (structure == null) { decomposed.put(path, NULL); continue; } if (Types.isSimple(structure)) { decomposed.put(path, structure); continue; } Map<Path,Object> decomposedMap = decomposeStructure(structure); for (Map.Entry<Path,Object> decomposedEntry : decomposedMap.entrySet()) { decomposed.put(path.concat(decomposedEntry.getKey()), decomposedEntry.getValue()); } } return decomposed; } private  Decomposer(); }
Decomposer { public Map<Path,Object> decompose(Map<Path,Object> structures) { if (structures == null) { throw new IllegalArgumentException("structures is null"); } Map<Path,Object> decomposed = new HashMap<Path,Object>(structures.size()); for (Map.Entry<Path,Object> entry : structures.entrySet()) { Object structure = entry.getValue(); Path path = entry.getKey(); if (structure == null) { decomposed.put(path, NULL); continue; } if (Types.isSimple(structure)) { decomposed.put(path, structure); continue; } Map<Path,Object> decomposedMap = decomposeStructure(structure); for (Map.Entry<Path,Object> decomposedEntry : decomposedMap.entrySet()) { decomposed.put(path.concat(decomposedEntry.getKey()), decomposedEntry.getValue()); } } return decomposed; } private  Decomposer(); static Decomposer get(); Map<Path,Object> decompose(Map<Path,Object> structures); }
Decomposer { public Map<Path,Object> decompose(Map<Path,Object> structures) { if (structures == null) { throw new IllegalArgumentException("structures is null"); } Map<Path,Object> decomposed = new HashMap<Path,Object>(structures.size()); for (Map.Entry<Path,Object> entry : structures.entrySet()) { Object structure = entry.getValue(); Path path = entry.getKey(); if (structure == null) { decomposed.put(path, NULL); continue; } if (Types.isSimple(structure)) { decomposed.put(path, structure); continue; } Map<Path,Object> decomposedMap = decomposeStructure(structure); for (Map.Entry<Path,Object> decomposedEntry : decomposedMap.entrySet()) { decomposed.put(path.concat(decomposedEntry.getKey()), decomposedEntry.getValue()); } } return decomposed; } private  Decomposer(); static Decomposer get(); Map<Path,Object> decompose(Map<Path,Object> structures);  }