@Test(groups = "unit") public void composeSimpleObjectsWithSimplePaths() throws Exception { Map<Path,Object> simpleObjects = new HashMap<Path,Object>(); simpleObjects.put(DefaultPath.fromStrings("x"), ""); simpleObjects.put(DefaultPath.fromStrings("y"), 42); simpleObjects.put(DefaultPath.fromStrings("z"), true); simpleObjects.put(DefaultPath.fromStrings("N"), null); Object result = composer.compose(simpleObjects); Map<String,Object> expectedResult = new HashMap<String,Object>(); for (Map.Entry<Path,Object> entry : simpleObjects.entrySet()) { expectedResult.put(entry.getKey().head(), entry.getValue()); } assertEquals(result, expectedResult); }
public Object compose(Map<Path,Object> simpleObjects) { if (simpleObjects == null) { throw new IllegalArgumentException("simpleObject is null"); } if (simpleObjects.isEmpty()) { return Collections.emptyMap(); } if (simpleObjects.size() == 1 && simpleObjects.keySet().iterator().next().size() == 0) { return simpleObjects.values().iterator().next(); } return transformLists(composeMap(simpleObjects)); }
Composer { public Object compose(Map<Path,Object> simpleObjects) { if (simpleObjects == null) { throw new IllegalArgumentException("simpleObject is null"); } if (simpleObjects.isEmpty()) { return Collections.emptyMap(); } if (simpleObjects.size() == 1 && simpleObjects.keySet().iterator().next().size() == 0) { return simpleObjects.values().iterator().next(); } return transformLists(composeMap(simpleObjects)); } }
Composer { public Object compose(Map<Path,Object> simpleObjects) { if (simpleObjects == null) { throw new IllegalArgumentException("simpleObject is null"); } if (simpleObjects.isEmpty()) { return Collections.emptyMap(); } if (simpleObjects.size() == 1 && simpleObjects.keySet().iterator().next().size() == 0) { return simpleObjects.values().iterator().next(); } return transformLists(composeMap(simpleObjects)); } private  Composer(); }
Composer { public Object compose(Map<Path,Object> simpleObjects) { if (simpleObjects == null) { throw new IllegalArgumentException("simpleObject is null"); } if (simpleObjects.isEmpty()) { return Collections.emptyMap(); } if (simpleObjects.size() == 1 && simpleObjects.keySet().iterator().next().size() == 0) { return simpleObjects.values().iterator().next(); } return transformLists(composeMap(simpleObjects)); } private  Composer(); static Composer get(); Object compose(Map<Path,Object> simpleObjects); }
Composer { public Object compose(Map<Path,Object> simpleObjects) { if (simpleObjects == null) { throw new IllegalArgumentException("simpleObject is null"); } if (simpleObjects.isEmpty()) { return Collections.emptyMap(); } if (simpleObjects.size() == 1 && simpleObjects.keySet().iterator().next().size() == 0) { return simpleObjects.values().iterator().next(); } return transformLists(composeMap(simpleObjects)); } private  Composer(); static Composer get(); Object compose(Map<Path,Object> simpleObjects);  }