コード例 #1
0
  @Override
  public boolean load(Properties baseProperties) {
    initialize();
    LOGGER.info("Loading {} ...", propertiesFile);
    if (!Files.exists(propertiesFile)) {
      LOGGER.warn("No {}", propertiesFile);
      return false;
    }

    FileBasedConfig cfg = new FileBasedConfig(propertiesFile.toFile(), FS.DETECTED);
    try {
      cfg.load();
    } catch (ConfigInvalidException e) {
      LOGGER.info("{} has invalid format: {}", propertiesFile, e.getMessage());
      return false;
    } catch (IOException e) {
      LOGGER.info("Cannot read {}: {}", propertiesFile, e.getMessage());
      return false;
    }
    for (Section section : getSections()) {
      if (baseProperties != null) {
        Sections.fromConfig(section, baseProperties.toConfig(), cfg);
      } else {
        Sections.fromConfig(section, cfg);
      }
      Sections.normalize(section);
    }
    return true;
  }
コード例 #2
0
 @Override
 public Config toConfig() {
   Config config = new Config();
   for (Section section : sections) {
     config = Sections.toConfig(section, config);
   }
   return config;
 }
コード例 #3
0
 private void initialize() {
   for (Section section : sections) {
     Sections.initialize(section);
   }
 }