@Test public void canIncludeFiles() throws Exception { String yaml = "" + "include: %s\n" + "metrics:\n" + " graphite:\n" + " port: 2004\n"; String include = "" + "metrics:\n" + " graphite:\n" + " port: 2003\n" + " intervalMillis: 5000\n"; testYamlWithInclude(yaml, include, yamlConfig -> { assertThat(yamlConfig.get("metrics.graphite.intervalMillis", Integer.class), isValue(5000)); assertThat(yamlConfig.get("metrics.graphite.port", Integer.class), isValue(2004)); }); }
@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();  }