@Test public void testComplexMergeRequired() throws IOException { Yaml toMerge = new YamlFile(getClass(), YAMLCONFIGURATION_YAML); Map<String, Object> baseMap = (Map) toMerge.dataTree(); MergedYaml mergedYaml = new MergedYaml(ImmutableList.of(toMerge, toMerge)); String formatted = mergedYaml.formatted(); Object dataTree = mergedYaml.dataTree(); assertTrue(dataTree instanceof Map); Map<String, Object> map = (Map) dataTree; doubledValues(formatted, baseMap, map, "annotators"); doubledValues(formatted, baseMap, map, "consumers"); madeList(formatted, map, "example"); madeList(formatted, map, "collectionreader"); }
@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();  }