com.typesafe.config.Config.isResolved()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中com.typesafe.config.Config.isResolved()方法的一些代码示例,展示了Config.isResolved()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.isResolved()方法的具体详情如下:
包路径:com.typesafe.config.Config
类名称:Config
方法名:isResolved

Config.isResolved介绍

[英]Checks whether the config is completely resolved. After a successful call to Config#resolve() it will be completely resolved, but after calling Config#resolve(ConfigResolveOptions) with allowUnresolved set in the options, it may or may not be completely resolved. A newly-loaded config may or may not be completely resolved depending on whether there were substitutions present in the file.
[中]检查配置是否已完全解析。成功调用Config#resolve()后,它将被完全解析,但在使用选项中设置的allowUnresolved调用Config#resolve(ConfigResolveOptions)后,它可能会被完全解析,也可能不会被完全解析。根据文件中是否存在替换,新加载的配置可能会完全解析,也可能不会完全解析。

代码示例

代码示例来源:origin: apache/incubator-gobblin

/**
 * Checks if the {@link FlowTemplate} is resolvable using the provided {@link Config} object. A {@link FlowTemplate}
 * is resolvable only if each of the {@link JobTemplate}s in the flow is resolvable
 * @param userConfig User supplied Config
 * @return true if the {@link FlowTemplate} is resolvable
 */
@Override
public boolean isResolvable(Config userConfig, DatasetDescriptor inputDescriptor, DatasetDescriptor outputDescriptor)
  throws SpecNotFoundException, JobTemplate.TemplateException {
 Config inputDescriptorConfig = inputDescriptor.getRawConfig().atPath(DatasetDescriptorConfigKeys.FLOW_EDGE_INPUT_DATASET_DESCRIPTOR_PREFIX);
 Config outputDescriptorConfig = outputDescriptor.getRawConfig().atPath(DatasetDescriptorConfigKeys.FLOW_EDGE_OUTPUT_DATASET_DESCRIPTOR_PREFIX);
 userConfig = userConfig.withFallback(inputDescriptorConfig).withFallback(outputDescriptorConfig);
 ConfigResolveOptions resolveOptions = ConfigResolveOptions.defaults().setAllowUnresolved(true);
 for (JobTemplate template: this.jobTemplates) {
  Config templateConfig = template.getResolvedConfig(userConfig).resolve(resolveOptions);
  if (!template.getResolvedConfig(userConfig).resolve(resolveOptions).isResolved()) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: dremio/dremio-oss

@Override
public boolean isResolved() {
 return config.isResolved();
}

代码示例来源:origin: org.apache.gobblin/gobblin-service

/**
 * Checks if the {@link FlowTemplate} is resolvable using the provided {@link Config} object. A {@link FlowTemplate}
 * is resolvable only if each of the {@link JobTemplate}s in the flow is resolvable
 * @param userConfig User supplied Config
 * @return true if the {@link FlowTemplate} is resolvable
 */
@Override
public boolean isResolvable(Config userConfig, DatasetDescriptor inputDescriptor, DatasetDescriptor outputDescriptor)
  throws SpecNotFoundException, JobTemplate.TemplateException {
 Config inputDescriptorConfig = inputDescriptor.getRawConfig().atPath(DatasetDescriptorConfigKeys.FLOW_EDGE_INPUT_DATASET_DESCRIPTOR_PREFIX);
 Config outputDescriptorConfig = outputDescriptor.getRawConfig().atPath(DatasetDescriptorConfigKeys.FLOW_EDGE_OUTPUT_DATASET_DESCRIPTOR_PREFIX);
 userConfig = userConfig.withFallback(inputDescriptorConfig).withFallback(outputDescriptorConfig);
 ConfigResolveOptions resolveOptions = ConfigResolveOptions.defaults().setAllowUnresolved(true);
 for (JobTemplate template: this.jobTemplates) {
  Config templateConfig = template.getResolvedConfig(userConfig).resolve(resolveOptions);
  if (!template.getResolvedConfig(userConfig).resolve(resolveOptions).isResolved()) {
   return false;
  }
 }
 return true;
}

相关文章