當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。