@Test public void testAsConfigFilter() { Config config = Config.builder() .sources(ConfigSources.create( Map.of( "aaa.bbb.name", "app-name", "aaa.bbb.url", "URL0", "aaa.anything", "1", "bbb", "ahoy" ))) .addFilter(new OverrideConfigFilter(() -> OverrideSource.OverrideData.createFromWildcards( Map.of("*.*.url", "URL1") .entrySet() .stream() .map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue())) .collect(Collectors.toList())).data())) .disableEnvironmentVariablesSource() .disableSystemPropertiesSource() .build(); assertThat(config.get("aaa.bbb.name").asString(), is(ConfigValues.simpleValue("app-name"))); assertThat(config.get("aaa.bbb.url").asString(), is(ConfigValues.simpleValue("URL1"))); assertThat(config.get("aaa.ccc.url").exists(), is(false)); assertThat(config.get("aaa.anything").asInt(), is(ConfigValues.simpleValue(1))); assertThat(config.get("bbb").asString(), is(ConfigValues.simpleValue("ahoy"))); assertThat(config.get("bbb.ccc.url").exists(), is(false)); }
static Builder builder(Map<String, String> overrideValues) { return new Builder(overrideValues.entrySet() .stream() .map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue())) .collect(Collectors.toList())); }
InMemoryOverrideSource implements OverrideSource { static Builder builder(Map<String, String> overrideValues) { return new Builder(overrideValues.entrySet() .stream() .map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue())) .collect(Collectors.toList())); } }
InMemoryOverrideSource implements OverrideSource { static Builder builder(Map<String, String> overrideValues) { return new Builder(overrideValues.entrySet() .stream() .map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue())) .collect(Collectors.toList())); } private  InMemoryOverrideSource(Builder builder); }
InMemoryOverrideSource implements OverrideSource { static Builder builder(Map<String, String> overrideValues) { return new Builder(overrideValues.entrySet() .stream() .map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue())) .collect(Collectors.toList())); } private  InMemoryOverrideSource(Builder builder); @Override Optional<OverrideContent> load(); }
InMemoryOverrideSource implements OverrideSource { static Builder builder(Map<String, String> overrideValues) { return new Builder(overrideValues.entrySet() .stream() .map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue())) .collect(Collectors.toList())); } private  InMemoryOverrideSource(Builder builder); @Override Optional<OverrideContent> load();  }