@Test public void testSimpleMergeRequired() throws IOException { String yaml1 = "test: value1"; String yaml2 = "test: \n- value2\n- value3"; MergedYaml mergedYaml = new MergedYaml(ImmutableList.of(new YamlString(yaml1), new YamlString(yaml2))); Object dataTree = mergedYaml.dataTree(); assertTrue(dataTree instanceof Map); Map<String, Object> map = (Map) dataTree; assertTrue(map.containsKey("test")); assertTrue(map.get("test") instanceof List); List<Object> value = (List<Object>) map.get("test"); assertTrue(value.contains("value1")); assertTrue(value.contains("value2")); assertTrue(value.contains("value3")); }
@Override @SuppressWarnings("unchecked") public Object dataTree() throws IOException { Map<String, Object> dataTree = new LinkedHashMap<>(); for (Yaml yaml : yamls) { Object object = yaml.dataTree(); if (object instanceof Map<?, ?>) { Map<String, Object> subTree = (Map<String, Object>) object; for (Entry<String, Object> e : subTree.entrySet()) { mergeWithDataTree(dataTree, e); } } } return dataTree; }
MergedYaml extends AbstractBaseYaml { @Override @SuppressWarnings("unchecked") public Object dataTree() throws IOException { Map<String, Object> dataTree = new LinkedHashMap<>(); for (Yaml yaml : yamls) { Object object = yaml.dataTree(); if (object instanceof Map<?, ?>) { Map<String, Object> subTree = (Map<String, Object>) object; for (Entry<String, Object> e : subTree.entrySet()) { mergeWithDataTree(dataTree, e); } } } return dataTree; } }
MergedYaml extends AbstractBaseYaml { @Override @SuppressWarnings("unchecked") public Object dataTree() throws IOException { Map<String, Object> dataTree = new LinkedHashMap<>(); for (Yaml yaml : yamls) { Object object = yaml.dataTree(); if (object instanceof Map<?, ?>) { Map<String, Object> subTree = (Map<String, Object>) object; for (Entry<String, Object> e : subTree.entrySet()) { mergeWithDataTree(dataTree, e); } } } return dataTree; } MergedYaml(List<Yaml> yamls); }
MergedYaml extends AbstractBaseYaml { @Override @SuppressWarnings("unchecked") public Object dataTree() throws IOException { Map<String, Object> dataTree = new LinkedHashMap<>(); for (Yaml yaml : yamls) { Object object = yaml.dataTree(); if (object instanceof Map<?, ?>) { Map<String, Object> subTree = (Map<String, Object>) object; for (Entry<String, Object> e : subTree.entrySet()) { mergeWithDataTree(dataTree, e); } } } return dataTree; } MergedYaml(List<Yaml> yamls); @Override @SuppressWarnings("unchecked") Object dataTree(); }
MergedYaml extends AbstractBaseYaml { @Override @SuppressWarnings("unchecked") public Object dataTree() throws IOException { Map<String, Object> dataTree = new LinkedHashMap<>(); for (Yaml yaml : yamls) { Object object = yaml.dataTree(); if (object instanceof Map<?, ?>) { Map<String, Object> subTree = (Map<String, Object>) object; for (Entry<String, Object> e : subTree.entrySet()) { mergeWithDataTree(dataTree, e); } } } return dataTree; } MergedYaml(List<Yaml> yamls); @Override @SuppressWarnings("unchecked") Object dataTree();  }