@Test public void canSubstituteArrayElements() { String yaml = "" + "array:\n" + "- ${element1}\n" + "- ${element2}\n" + "- ${element3:gamma}\n" + "- ${element4}\n"; YamlConfiguration yamlConfig = config(yaml, ImmutableMap.of("element1", "alpha", "element2", "beta", "element4", "delta")); assertThat(yamlConfig.get("array[0]"), isValue("alpha")); assertThat(yamlConfig.get("array[1]"), isValue("beta")); assertThat(yamlConfig.get("array[2]"), isValue("gamma")); assertThat(yamlConfig.get("array[3]"), isValue("delta")); }
@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();  }