Skip to content

Commit

Permalink
Revert indent changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
batsatt committed Mar 18, 2019
1 parent 3faa087 commit b29f121
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 65 deletions.
64 changes: 31 additions & 33 deletions config/config/src/main/java/io/helidon/config/ConfigSources.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
import io.helidon.config.spi.AbstractConfigSource;
import io.helidon.config.spi.AbstractParsableConfigSource;
import io.helidon.config.spi.ConfigNode;
import io.helidon.config.spi.ConfigParser.Content;
import io.helidon.config.spi.ConfigParser;
import io.helidon.config.spi.ConfigSource;

import static java.time.Instant.now;
import static java.util.Objects.requireNonNull;

/**
Expand All @@ -70,7 +69,6 @@ private ConfigSources() {

/**
* Provides an empty config source.
*
* @return empty config source
*/
public static ConfigSource empty() {
Expand All @@ -94,7 +92,7 @@ public static ConfigSource create(Config config) {
* and returns it when {@link ConfigSource#load()} is invoked.
*
* @param objectNode hierarchical configuration representation that will be
* returned by {@link ConfigSource#load()}
* returned by {@link ConfigSource#load()}
* @return new instance of {@link ConfigSource}
* @see ConfigNode.ObjectNode
* @see ConfigNode.ListNode
Expand All @@ -120,38 +118,38 @@ public Optional<ConfigNode.ObjectNode> load() throws ConfigException {
* Provides a {@link ConfigSource} from the provided {@link Readable readable content} and
* with the specified {@code mediaType}.
* <p>
* {@link Instant#now()} is the {@link Content#stamp() content timestamp}.
* {@link Instant#now()} is the {@link ConfigParser.Content#stamp() content timestamp}.
*
* @param readable a {@code Readable} providing the configuration content
* @param readable a {@code Readable} providing the configuration content
* @param mediaType a configuration media type
* @return a config source
*/
public static ConfigSource create(Readable readable, String mediaType) {
return InMemoryConfigSource.builder()
.mediaType(mediaType)
.changesExecutor(Runnable::run)
.changesMaxBuffer(1)
.content("Readable", Content.create(readable, mediaType, Optional.of(now())))
.build();
.mediaType(mediaType)
.changesExecutor(Runnable::run)
.changesMaxBuffer(1)
.content("Readable", ConfigParser.Content.create(readable, mediaType, Optional.of(Instant.now())))
.build();
}

/**
* Provides a {@link ConfigSource} from the provided {@code String} content and
* with the specified {@code mediaType}.
* <p>
* {@link Instant#now()} is the {@link Content#stamp() content timestamp}.
* {@link Instant#now()} is the {@link ConfigParser.Content#stamp() content timestamp}.
*
* @param content a configuration content
* @param mediaType a configuration media type
* @return a config source
*/
public static ConfigSource create(String content, String mediaType) {
return InMemoryConfigSource.builder()
.mediaType(mediaType)
.changesExecutor(Runnable::run)
.changesMaxBuffer(1)
.content("String", Content.create(new StringReader(content), mediaType, Optional.of(now())))
.build();
.mediaType(mediaType)
.changesExecutor(Runnable::run)
.changesMaxBuffer(1)
.content("String", ConfigParser.Content.create(new StringReader(content), mediaType, Optional.of(Instant.now())))
.build();
}

/**
Expand Down Expand Up @@ -208,7 +206,7 @@ public static MapBuilder create(Properties properties, String name) {
* Provides a {@link ConfigSource} from a {@link Supplier sourceSupplier}, adding the
* specified {@code prefix} to the keys in the source.
*
* @param key key prefix to be added to all keys
* @param key key prefix to be added to all keys
* @param sourceSupplier a config source supplier
* @return new @{code ConfigSource} for the newly-prefixed content
*/
Expand Down Expand Up @@ -249,7 +247,7 @@ public static ConfigSource environmentVariables() {
* @return builder for a {@code ConfigSource} for the classpath-based resource
*/
public static AbstractParsableConfigSource.Builder
<? extends AbstractParsableConfigSource.Builder<?, Path>, Path> classpath(String resource) {
<? extends AbstractParsableConfigSource.Builder<?, Path>, Path> classpath(String resource) {
return new ClasspathConfigSource.ClasspathBuilder(resource);
}

Expand All @@ -261,7 +259,7 @@ <? extends AbstractParsableConfigSource.Builder<?, Path>, Path> classpath(String
* @return builder for the file-based {@code ConfigSource}
*/
public static AbstractParsableConfigSource.Builder
<? extends AbstractParsableConfigSource.Builder<?, Path>, Path> file(String path) {
<? extends AbstractParsableConfigSource.Builder<?, Path>, Path> file(String path) {
return new FileConfigSource.FileBuilder(Paths.get(path));
}

Expand All @@ -273,7 +271,7 @@ <? extends AbstractParsableConfigSource.Builder<?, Path>, Path> file(String path
* @return new Builder instance
*/
public static AbstractConfigSource.Builder
<? extends AbstractConfigSource.Builder<?, Path>, Path> directory(String path) {
<? extends AbstractConfigSource.Builder<?, Path>, Path> directory(String path) {
return new DirectoryConfigSource.DirectoryBuilder(Paths.get(path));
}

Expand All @@ -286,7 +284,7 @@ <? extends AbstractConfigSource.Builder<?, Path>, Path> directory(String path) {
* @see #url(URL)
*/
public static AbstractParsableConfigSource.Builder
<? extends AbstractParsableConfigSource.Builder<?, URL>, URL> url(URL url) {
<? extends AbstractParsableConfigSource.Builder<?, URL>, URL> url(URL url) {
return new UrlConfigSource.UrlBuilder(url);
}

Expand Down Expand Up @@ -373,9 +371,9 @@ public static CompositeBuilder create(List<Supplier<ConfigSource>> configSources
@SafeVarargs
public static CompositeBuilder load(Supplier<ConfigSource>... metaSources) {
return load(Config.builder(metaSources)
.disableEnvironmentVariablesSource()
.disableSystemPropertiesSource()
.build());
.disableEnvironmentVariablesSource()
.disableSystemPropertiesSource()
.build());
}

/**
Expand Down Expand Up @@ -407,12 +405,12 @@ public static CompositeBuilder load(Supplier<ConfigSource>... metaSources) {
*/
public static CompositeBuilder load(Config metaConfig) {
List<Supplier<ConfigSource>> sources = metaConfig.get(SOURCES_KEY)
.asNodeList()
.orElse(CollectionsHelper.listOf())
.stream()
.map(node -> node.as(ConfigSource::create))
.map(ConfigValue::get)
.collect(Collectors.toList());
.asNodeList()
.orElse(CollectionsHelper.listOf())
.stream()
.map(node -> node.as(ConfigSource::create))
.map(ConfigValue::get)
.collect(Collectors.toList());

return ConfigSources.create(sources);
}
Expand Down Expand Up @@ -673,8 +671,8 @@ public ConfigSource build() {
finalConfigSources.addAll(configSources);

final MergingStrategy finalMergingStrategy = mergingStrategy != null
? mergingStrategy
: new FallbackMergingStrategy();
? mergingStrategy
: new FallbackMergingStrategy();

return createCompositeConfigSource(finalConfigSources, finalMergingStrategy, changesExecutor, debounceTimeout,
changesMaxBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,24 @@ public void testFromConfig() {

ConfigSource originConfigSource = ConfigSources.create(source).build();
Config originConfig = Config.builder(originConfigSource)
.disableEnvironmentVariablesSource()
.disableSystemPropertiesSource()
.build();
.disableEnvironmentVariablesSource()
.disableSystemPropertiesSource()
.build();

ConfigSource configSource = ConfigSources.create(originConfig);
Config copy = Config.builder(configSource)
.disableEnvironmentVariablesSource()
.disableSystemPropertiesSource()
.build();
.disableEnvironmentVariablesSource()
.disableSystemPropertiesSource()
.build();

assertThat(ConfigDiff.from(originConfig, copy).isEmpty(), is(true));
}

@Test
public void testPrefix() {
assertThat(Config.create(prefixed("security", ConfigSources.create(mapOf("credentials.username", "libor"))))
.get("security.credentials.username")
.asString(),
.get("security.credentials.username")
.asString(),
is(ConfigValues.simpleValue("libor")));

}
Expand Down Expand Up @@ -132,13 +132,13 @@ public void testLoadSingleSource() {
System.setProperty(TEST_SYS_PROP_NAME, TEST_SYS_PROP_VALUE);

ConfigSource meta1 = ConfigSources.create(
ObjectNode.builder()
.addList("sources", ListNode.builder()
.addObject(ObjectNode.builder()
.addValue("type", "system-properties")
.build())
.build())
.build());
ObjectNode.builder()
.addList("sources", ListNode.builder()
.addObject(ObjectNode.builder()
.addValue("type", "system-properties")
.build())
.build())
.build());

ConfigSource source = ConfigSources.load(meta1).build();
source.init(mock(ConfigContext.class));
Expand All @@ -152,26 +152,26 @@ public void testLoadMultipleSource() {

//meta1's `sources` property is used
ConfigSource meta1 = ConfigSources.create(
ObjectNode.builder()
.addList("sources", ListNode.builder()
.addObject(ObjectNode.builder()
.addValue("type", "classpath")
.addObject("properties", ObjectNode.builder()
.addValue("resource", "io/helidon/config/application.properties")
.build())
.build())
.build())
.build());
ObjectNode.builder()
.addList("sources", ListNode.builder()
.addObject(ObjectNode.builder()
.addValue("type", "classpath")
.addObject("properties", ObjectNode.builder()
.addValue("resource", "io/helidon/config/application.properties")
.build())
.build())
.build())
.build());

//meta2's `sources` property is ignored
ConfigSource meta2 = ConfigSources.create(
ObjectNode.builder()
.addList("sources", ListNode.builder()
.addObject(ObjectNode.builder()
.addValue("type", "system-properties")
.build())
.build())
.build());
ObjectNode.builder()
.addList("sources", ListNode.builder()
.addObject(ObjectNode.builder()
.addValue("type", "system-properties")
.build())
.build())
.build());

//meta1 has precedence over meta2
ConfigSource source = ConfigSources.load(meta1, meta2).build();
Expand Down

0 comments on commit b29f121

Please sign in to comment.