@Test public void overridesPropertiesWithReplacedPlaceholders() throws Exception { Map<String, String> systemProperties = ImmutableMap.of("FOO", "production1"); String yaml = "" + "include: %s\n" + "foo: \"\"\n"; String include = "" + "foo: ${FOO:}-\n" + "domain: de.${foo}example.com\n"; File file = createTestFile(); try { writeFile(file, include); String yamlWithResolvedInclude = format(yaml, file); YamlConfiguration yamlConfig = config(yamlWithResolvedInclude, systemProperties); assertThat(yamlConfig.get("foo", String.class), isValue("")); assertThat(yamlConfig.get("domain", String.class), isValue("de.example.com")); } finally { deleteFile(file); } }
@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();  }