本文整理汇总了Java中com.typesafe.config.ConfigResolveOptions类的典型用法代码示例。如果您正苦于以下问题:Java ConfigResolveOptions类的具体用法?Java ConfigResolveOptions怎么用?Java ConfigResolveOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigResolveOptions类属于com.typesafe.config包,在下文中一共展示了ConfigResolveOptions类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConfig
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
@Override
public Config getConfig() throws IOException {
PathMatcher pathMatcher;
try {
pathMatcher = FileSystems.getDefault().getPathMatcher(inputFilePattern);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"Invalid input file pattern: " + inputFilePattern);
}
try (Stream<Path> pathStream = Files.walk(baseDirectory)) {
return pathStream
.filter(p -> Files.isRegularFile(p) && pathMatcher.matches(p))
.map(p -> ConfigFactory.parseFile(p.toFile()))
.reduce(ConfigFactory.empty(), Config::withFallback)
.resolve(
ConfigResolveOptions.defaults()
.setAllowUnresolved(true)
.setUseSystemEnvironment(false)
);
}
}
示例2: load
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
/**
* Evaluates the {@link ConfigSource}s, {@link #bind(Class) bind}s the
* resulting {@link Config}, then evaluates the {@link ConfigSource}s
* again.
*
* <p>The second evaluation takes place to allow sources to utilize
* values produced by other config sources.</p>
*/
public Config load() {
ConfigResolveOptions resolveOptions = getResolveOptions();
HashMapBindings bindings = this.bindings;
Config config = emptyConfig();
for (int i = 0; i < 2; i++) {
config = emptyConfig();
for (ConfigSource source
: sources.fromHighestToLowestPrecedence()) {
config = config.withFallback(source.load(bindings));
}
config = config.resolve(resolveOptions);
bindings = bindings.set(Config.class, config);
}
return config;
}
示例3: asMap
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
/**
* @return All properties that are currently loaded from internal and
* external files
*/
@Override
public Map<String, Object> asMap() {
return configuration
.resolve(ConfigResolveOptions.defaults().setUseSystemEnvironment(true).setAllowUnresolved(true))
.root()
.unwrapped();
}
示例4: getResolveOptions
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
private ConfigResolveOptions getResolveOptions() {
Binding<ConfigResolveOptions> resolveOptionsBinding =
bindings.get(ConfigResolveOptions.class);
if (resolveOptionsBinding.isPresent()) {
return resolveOptionsBinding.get();
} else {
return ConfigResolveOptions.defaults();
}
}
示例5: resolve
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
@Override
public Config resolve(ConfigResolveOptions options) {
return c.resolve(options);
}
示例6: resolve
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
@Override
public Config resolve(ConfigResolveOptions options) {
return config.resolve(options);
}
示例7: resolveWith
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
@Override
public Config resolveWith(Config arg0, ConfigResolveOptions arg1) {
return resolveWith(arg0, arg1);
}
示例8: defaultBindings
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
/**
* Some default bindings that most config factories will need.
*
* <ul>
* <li>
* {@link ClassLoader} →
* {@link Thread#currentThread()}.{@link Thread#getContextClassLoader()
* getContextClassLoader()}
* </li>
* <li>
* {@link com.typesafe.config.ConfigParseOptions} →
* {@link com.typesafe.config.ConfigParseOptions#defaults()}
* </li>
* <li>
* {@link com.typesafe.config.ConfigResolveOptions} →
* {@link com.typesafe.config.ConfigParseOptions#defaults()}
* </li>
* <li>
* {@link com.typesafe.config.Config} →
* {@link com.typesafe.config.ConfigFactory#empty()
* ConfigFactory.empty()}
* </li>
* </ul>
*/
public static Bindings defaultBindings() {
return noHashMapBindings()
.set(
ClassLoader.class,
Thread.currentThread().getContextClassLoader()
)
.set(
ConfigParseOptions.class,
ConfigParseOptions.defaults()
)
.set(
ConfigResolveOptions.class,
ConfigResolveOptions.defaults()
)
.set(
Config.class,
emptyConfig()
);
}
示例9: withResolveOptions
import com.typesafe.config.ConfigResolveOptions; //导入依赖的package包/类
/**
* Binds a {@link ConfigResolveOptions} instance.
*
* <p>Equivalent to</p>
* <pre>{@code
* bind(ConfigResolveOptions.class).toInstance(resolveOptions)
* }</pre>
*
* @see #bind(Class)
*/
public ConfigFactory
withResolveOptions(ConfigResolveOptions resolveOptions) {
return bind(ConfigResolveOptions.class)
.toInstance(checkNotNull(resolveOptions));
}