当前位置: 首页>>代码示例>>Java>>正文


Java Config.checkValid方法代码示例

本文整理汇总了Java中com.typesafe.config.Config.checkValid方法的典型用法代码示例。如果您正苦于以下问题:Java Config.checkValid方法的具体用法?Java Config.checkValid怎么用?Java Config.checkValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.typesafe.config.Config的用法示例。


在下文中一共展示了Config.checkValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGameConfiguration

import com.typesafe.config.Config; //导入方法依赖的package包/类
Config getGameConfiguration() {

            Config referenceConfig = cfg();

            Config customConfig = ConfigFactory.parseMap(builderConfig).withFallback(referenceConfig);
            Map<String, Object> executableConfig = new HashMap<>();


            if (!customConfig.hasPath(GAME_EXE_PATH)) {
                executableConfig.put(GAME_EXE_PATH, findExecutablePath().toString());
            } else {
                executableConfig.put(GAME_EXE_PATH, customConfig.getString(GAME_EXE_PATH));
            }

            Path executablePath = Paths.get((String) executableConfig.get(GAME_EXE_PATH));
            String baseBuild = toNewestBaseBuild().apply(executablePath.resolve(VERSIONS_DIR));
            Path buildPath = executablePath.resolve(Paths.get(VERSIONS_DIR, baseBuild));
            String exeFile = toNewestExeFile().apply(buildPath);

            executableConfig.put(GAME_EXE_BUILD, baseBuild);
            executableConfig.put(GAME_EXE_FILE, exeFile);
            executableConfig.put(GAME_EXE_IS_64, exeFile.contains(X64_SUFFIX));

            if (!customConfig.hasPath(GAME_EXE_DATA_VER)) {
                Optional<GameVersion> gameVersion = Versions.versionFor(
                        Integer.parseInt(baseBuild.replaceFirst(BUILD_PREFIX, "")));
                gameVersion.ifPresent(ver -> executableConfig.put(GAME_EXE_DATA_VER, ver.getDataHash()));
            }

            Config gameConfig = ConfigFactory.parseMap(executableConfig).withFallback(customConfig);
            gameConfig.checkValid(referenceConfig);

            return gameConfig;
        }
 
开发者ID:ocraft,项目名称:ocraft-s2client,代码行数:35,代码来源:S2Controller.java

示例2: check

import com.typesafe.config.Config; //导入方法依赖的package包/类
private void check(){
  final Config inner = getInnerConfig();
  final Config ref = reference.resolve();

  // make sure types are right
  inner.checkValid(ref);

  // make sure we don't have any extra paths. these are typically typos.
  List<String> invalidPaths = new ArrayList<>();
  for(Entry<String, ConfigValue> entry : inner.entrySet()){
    if(!ref.hasPath(entry.getKey())){
      invalidPaths.add(entry.getKey());
    }
  }

  if(!invalidPaths.isEmpty()){
    StringBuilder sb = new StringBuilder();
    sb.append("Failure reading configuration file. The following properties were invalid:\n");
    for(String s : invalidPaths){
      sb.append("\t");
      sb.append(s);
      sb.append("\n");
    }

    throw new RuntimeException(sb.toString());
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:DremioConfig.java


注:本文中的com.typesafe.config.Config.checkValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。