本文整理了Java中com.typesafe.config.Config.isEmpty()
方法的一些代码示例,展示了Config.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.isEmpty()
方法的具体详情如下:
包路径:com.typesafe.config.Config
类名称:Config
方法名:isEmpty
[英]Returns true if the Config's root object contains no key-value pairs.
[中]如果配置的根对象不包含键值对,则返回true。
代码示例来源:origin: apache/drill
@Override
public boolean isEmpty() {
return c.isEmpty();
}
代码示例来源:origin: jooby-project/jooby
private static List<Config> modconf(final Collection<Object> bag) {
return bag.stream()
.filter(it -> it instanceof Jooby.Module)
.map(it -> ((Jooby.Module) it).config())
.filter(c -> !c.isEmpty())
.collect(Collectors.toList());
}
代码示例来源:origin: jooby-project/jooby
private Config conf(final boolean dev, final ClassLoader loader, final Config conf) {
final Config[] confs;
if (!dev) {
confs = new Config[]{
ConfigFactory.parseResources(loader,
"assets." + conf.getString("application.env").toLowerCase() + ".conf"),
ConfigFactory.parseResources(loader, "assets.dist.conf"),
ConfigFactory.parseResources(loader, "assets.conf")};
for (Config it : confs) {
if (!it.isEmpty()) {
return it.withFallback(conf).resolve();
}
}
}
return ConfigFactory.parseResources(loader, "assets.conf").withFallback(conf).resolve();
}
代码示例来源:origin: apache/incubator-gobblin
@Test
public void testGetOwnConfig() throws ConfigStoreCreationException, URISyntaxException, IOException {
String datasetName = "dataset-test-get-own-config";
Path datasetPath = new Path(CONFIG_DIR_PATH, datasetName);
try {
this.fs.mkdirs(datasetPath);
this.fs.create(new Path(datasetPath, "main.conf")).close();
ConfigKeyPath datasetConfigKey = SingleLinkedListConfigKeyPath.ROOT.createChild(datasetName);
Config config = this._simpleHadoopFilesystemConfigStore.getOwnConfig(datasetConfigKey, VERSION);
Assert.assertTrue(config.isEmpty());
} finally {
if (this.fs.exists(datasetPath)) {
this.fs.delete(datasetPath, true);
}
}
}
代码示例来源:origin: apache/incubator-gobblin
private void constructDataFlowTopologyWithConfig(Config routesConfig) {
Preconditions.checkArgument(routesConfig != null && !routesConfig.isEmpty(),
"Can not build topology without empty config");
Preconditions.checkArgument(this.source != null, "Can not build topology without source");
代码示例来源:origin: apache/incubator-gobblin
@Test
public void testGetFactoryConfig() {
FileBasedJobLockFactoryManager mgr = new FileBasedJobLockFactoryManager();
Config sysConfig1 = ConfigFactory.empty();
Assert.assertTrue(mgr.getFactoryConfig(sysConfig1).isEmpty());
Config sysConfig2 = sysConfig1.withValue("some.prop", ConfigValueFactory.fromAnyRef("test"));
Assert.assertTrue(mgr.getFactoryConfig(sysConfig2).isEmpty());
Config sysConfig3 =
sysConfig2.withValue(FileBasedJobLockFactoryManager.CONFIG_PREFIX + "." + FileBasedJobLockFactory.LOCK_DIR_CONFIG,
ConfigValueFactory.fromAnyRef("/tmp"));
Config factoryCfg3 = mgr.getFactoryConfig(sysConfig3);
Assert.assertEquals(factoryCfg3.getString(FileBasedJobLockFactory.LOCK_DIR_CONFIG), "/tmp");
}
代码示例来源:origin: apache/incubator-gobblin
/**
* A method to add tracking event configurations to a JobSpec.
* This enables {@link org.apache.gobblin.metrics.GobblinTrackingEvent}s
* to be emitted from each Gobblin job orchestrated by Gobblin-as-a-Service, which will then be used for tracking the
* execution status of the job.
* @param jobSpec representing a fully resolved {@link JobSpec}.
*/
private static void addTrackingEventConfig(JobSpec jobSpec, Config sysConfig) {
Config reportingConfig = ConfigUtils.getConfig(sysConfig, ConfigurationKeys.METRICS_REPORTING_CONFIGURATIONS_PREFIX, ConfigFactory.empty());
if (!reportingConfig.isEmpty()) {
Config jobConfig = jobSpec.getConfig().withFallback(reportingConfig.atPath(ConfigurationKeys.METRICS_REPORTING_CONFIGURATIONS_PREFIX));
boolean isSchemaRegistryEnabled = ConfigUtils.getBoolean(sysConfig, ConfigurationKeys.METRICS_REPORTING_KAFKA_USE_SCHEMA_REGISTRY, false);
if (isSchemaRegistryEnabled) {
String schemaRegistryUrl = ConfigUtils.getString(sysConfig, KafkaSchemaRegistry.KAFKA_SCHEMA_REGISTRY_URL, "");
if (!Strings.isNullOrEmpty(schemaRegistryUrl)) {
jobConfig = jobConfig.withValue(KafkaSchemaRegistry.KAFKA_SCHEMA_REGISTRY_URL, ConfigValueFactory.fromAnyRef(schemaRegistryUrl));
}
String schemaOverrideNamespace = ConfigUtils
.getString(sysConfig, KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_OVERRIDE_NAMESPACE, "");
if (!Strings.isNullOrEmpty(schemaOverrideNamespace)) {
jobConfig = jobConfig.withValue(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_OVERRIDE_NAMESPACE,
ConfigValueFactory.fromAnyRef(schemaOverrideNamespace));
}
}
jobSpec.setConfig(jobConfig);
}
}
代码示例来源:origin: org.apache.drill/drill-common
@Override
public boolean isEmpty() {
return c.isEmpty();
}
代码示例来源:origin: dremio/dremio-oss
@Override
public boolean isEmpty() {
return config.isEmpty();
}
代码示例来源:origin: org.jooby/jooby
private static List<Config> modconf(final Collection<Object> bag) {
return bag.stream()
.filter(it -> it instanceof Jooby.Module)
.map(it -> ((Jooby.Module) it).config())
.filter(c -> !c.isEmpty())
.collect(Collectors.toList());
}
代码示例来源:origin: io.lighty.core/lighty-controller
private static Config getAkkaConfigFromPath(final String pathToConfig) throws ConfigurationException {
Config akkaConfig = null;
try {
akkaConfig = ConfigFactory.parseFile(new File(pathToConfig));
} catch (ConfigException e) {
LOG.debug("Cannot read Akka config from filesystem: " + pathToConfig, e);
}
if (akkaConfig == null || akkaConfig.isEmpty()) {
// read from JAR resources on classpath
akkaConfig = ConfigFactory.parseResources(
ControllerConfigUtils.class.getClass().getClassLoader(),
pathToConfig);
if (akkaConfig.isEmpty()) {
throw new ConfigurationException("Cannot find Akka config on classpath: "
+ pathToConfig);
} else {
LOG.info("Used Akka config file from classpath: {}", pathToConfig);
return akkaConfig;
}
}
LOG.info("Used Akka config file from filesystem: {}", pathToConfig);
return akkaConfig;
}
}
代码示例来源:origin: graylog-labs/collector
public static Config parse(File configFile) {
Config config = null;
if (configFile.exists() && configFile.canRead()) {
config = ConfigFactory.parseFile(configFile);
if (config.isEmpty()) {
throw new Error("Empty configuration!");
}
} else {
throw new Error("Configuration file " + configFile + " does not exist or is not readable!");
}
return config;
}
}
代码示例来源:origin: org.apache.drill.exec/drill-java-exec
@VisibleForTesting
public DrillSqlLineApplication(String configName, String overrideConfigName) {
this.config = overrideConfig(overrideConfigName, loadConfig(configName));
if (config.isEmpty()) {
logger.warn("Was unable to find / load [{}]. Will use default SqlLine configuration.", configName);
}
}
代码示例来源:origin: org.nosceon.datolite/datolite-core
public Shutdownable start(Supplier<Application> application) {
Config configuration = (config.isEmpty()) ? ConfigFactory.load() : ConfigFactory.load(config);
Logging.configure(configuration);
DatoliteSystem system = Datolite.set(new DatoliteSystem(configuration));
getRuntime().addShutdownHook(new Thread(system.shutdownHook()));
try {
application.get().start();
}
catch (InitializationException e) {
throw e;
}
catch (Exception e) {
system.shutdown();
throw new InitializationException(e);
}
return system;
}
代码示例来源:origin: org.jooby/jooby-assets
private Config conf(final boolean dev, final ClassLoader loader, final Config conf) {
final Config[] confs;
if (!dev) {
confs = new Config[]{
ConfigFactory.parseResources(loader,
"assets." + conf.getString("application.env").toLowerCase() + ".conf"),
ConfigFactory.parseResources(loader, "assets.dist.conf"),
ConfigFactory.parseResources(loader, "assets.conf")};
for (Config it : confs) {
if (!it.isEmpty()) {
return it.withFallback(conf).resolve();
}
}
}
return ConfigFactory.parseResources(loader, "assets.conf").withFallback(conf).resolve();
}
代码示例来源:origin: io.github.interestinglab.waterdrop/waterdrop-core
@Override
public Config visitEntries(ConfigParser.EntriesContext ctx) {
Config entries = ConfigFactory.empty();
for (ConfigParser.PairContext pairContext : ctx.pair()) {
final Config pair = visit(pairContext);
if (pair != null && ! pair.isEmpty()) {
for (Map.Entry<String, ConfigValue> entry : pair.entrySet()) {
entries = entries.withValue(entry.getKey(), entry.getValue());
}
}
}
return entries;
}
代码示例来源:origin: gitblit/fathom
} else {
Config classpathConfig = loadConfig(configFileUrl);
if (classpathConfig.isEmpty()) {
log.warn("Empty config '{}'", configFileUrl);
} else {
代码示例来源:origin: io.github.interestinglab.waterdrop/waterdrop-core
@Override
public Config visitOutputBlock(ConfigParser.OutputBlockContext ctx) {
Config outputPluginList = ConfigFactory.empty();
List<ConfigValue> statements = new ArrayList<>();
for (ConfigParser.StatementContext statementContext: ctx.statement()) {
final Config statement = visit(statementContext);
if (statement != null && !statement.isEmpty()) {
statements.add(statement.root());
}
}
outputPluginList = outputPluginList.withValue("output", ConfigValueFactory.fromIterable(statements));
return outputPluginList;
}
代码示例来源:origin: io.github.interestinglab.waterdrop/waterdrop-core
@Override
public Config visitFilterBlock(ConfigParser.FilterBlockContext ctx) {
Config filterPluginList = ConfigFactory.empty();
List<ConfigValue> statements = new ArrayList<>();
for (ConfigParser.StatementContext statementContext: ctx.statement()) {
final Config statement = visit(statementContext);
if (statement != null && !statement.isEmpty()) {
statements.add(statement.root());
}
}
filterPluginList = filterPluginList.withValue("filter", ConfigValueFactory.fromIterable(statements));
return filterPluginList;
}
代码示例来源:origin: io.github.interestinglab.waterdrop/waterdrop-core
@Override
public Config visitPlugin(ConfigParser.PluginContext ctx) {
Config plugin = ConfigFactory.empty();
if (ctx.IDENTIFIER() != null) {
final String pluginName = ctx.IDENTIFIER().getText();
plugin = plugin.withValue("name", ConfigValueFactory.fromAnyRef(pluginName));
if (ctx.entries() != null) {
final Config entries = visit(ctx.entries());
if (entries != null && ! entries.isEmpty()) {
plugin = plugin.withValue("entries", entries.root());
} else {
plugin = plugin.withValue("entries", ConfigFactory.empty().root());
}
}
}
return plugin;
}
内容来源于网络,如有侵权,请联系作者删除!