@Test public void supportsMultipleIncludes() throws Exception { String yaml2 = "" + "include: %s\n" + "onlyIn2: alpha\n" + "override1With2: beta\n" + "override0With2: gamma\n" + "override0With1Then2: delta\n"; String yaml1 = "" + "include: %s\n" + "onlyIn1: abc\n" + "override1With2: def\n" + "override0With1: ghi\n" + "override0With1Then2: jkl\n"; String yaml0 = "" + "onlyIn0: foo\n" + "override0With1: bar\n" + "override0With2: baz\n" + "override0With1Then2: hw\n"; File[] testFiles = createTestFiles(2); yaml1 = format(yaml1, testFiles[0]); yaml2 = format(yaml2, testFiles[1]); try { writeFile(testFiles[0], yaml0); writeFile(testFiles[1], yaml1); YamlConfiguration yamlConfig = config(yaml2); assertThat(yamlConfig.get("onlyIn0"), isValue("foo")); assertThat(yamlConfig.get("onlyIn1"), isValue("abc")); assertThat(yamlConfig.get("onlyIn2"), isValue("alpha")); assertThat(yamlConfig.get("override0With1"), isValue("ghi")); assertThat(yamlConfig.get("override1With2"), isValue("beta")); assertThat(yamlConfig.get("override0With2"), isValue("gamma")); assertThat(yamlConfig.get("override0With1Then2"), isValue("delta")); } finally { deleteFiles(testFiles); } }
@Override public <T> Optional<T> get(String property, Class<T> tClass) { return nodeAt(property) .map(node -> { if (tClass == Path.class) { return (T) Paths.get(node.textValue()); } return parseNodeToClass(node, tClass); }); }
YamlConfiguration implements ExtensibleConfiguration<YamlConfiguration> { @Override public <T> Optional<T> get(String property, Class<T> tClass) { return nodeAt(property) .map(node -> { if (tClass == Path.class) { return (T) Paths.get(node.textValue()); } return parseNodeToClass(node, tClass); }); } }
YamlConfiguration implements ExtensibleConfiguration<YamlConfiguration> { @Override public <T> Optional<T> get(String property, Class<T> tClass) { return nodeAt(property) .map(node -> { if (tClass == Path.class) { return (T) Paths.get(node.textValue()); } return parseNodeToClass(node, tClass); }); } YamlConfiguration(JsonNode rootNode); }
YamlConfiguration implements ExtensibleConfiguration<YamlConfiguration> { @Override public <T> Optional<T> get(String property, Class<T> tClass) { return nodeAt(property) .map(node -> { if (tClass == Path.class) { return (T) Paths.get(node.textValue()); } return parseNodeToClass(node, tClass); }); } YamlConfiguration(JsonNode rootNode); @Override YamlConfiguration withParent(YamlConfiguration parent); @Override YamlConfiguration withOverrides(Map<String, String> overrides); @Override PlaceholderResolutionResult<YamlConfiguration> resolvePlaceholders(Map<String, String> overrides); @Override Optional<T> get(String property, Class<T> tClass); @Override X as(Class<X> type); @Override String toString(); JsonNode root(); }
YamlConfiguration implements ExtensibleConfiguration<YamlConfiguration> { @Override public <T> Optional<T> get(String property, Class<T> tClass) { return nodeAt(property) .map(node -> { if (tClass == Path.class) { return (T) Paths.get(node.textValue()); } return parseNodeToClass(node, tClass); }); } YamlConfiguration(JsonNode rootNode); @Override YamlConfiguration withParent(YamlConfiguration parent); @Override YamlConfiguration withOverrides(Map<String, String> overrides); @Override PlaceholderResolutionResult<YamlConfiguration> resolvePlaceholders(Map<String, String> overrides); @Override Optional<T> get(String property, Class<T> tClass); @Override X as(Class<X> type); @Override String toString(); JsonNode root();  }