/**
  * Loads a report template from an .ini file.
  *
  * @param iniFile the .ini file containing the definition of a report template
  * @return the template defined in the .ini file
  * @throws RuntimeException if the ini file cannot be parsed
  */
 public static ReportTemplate load(IniFile iniFile) {
   String settingsSectionKey =
       iniFile
           .sections()
           .stream()
           .filter(k -> k.toLowerCase().equals(ReportTemplateIniLoader.SETTINGS_SECTION))
           .findFirst()
           .orElseThrow(
               () ->
                   new IllegalArgumentException(
                       Messages.format(
                           "Report template INI file must contain a {} section",
                           ReportTemplateIniLoader.SETTINGS_SECTION)));
   PropertySet settingsSection = iniFile.section(settingsSectionKey);
   String reportType = settingsSection.value(ReportTemplateIniLoader.SETTINGS_REPORT_TYPE);
   ReportTemplateIniLoader<? extends ReportTemplate> iniLoader =
       LOADERS
           .stream()
           .filter(loader -> loader.getReportType().toLowerCase().equals(reportType.toLowerCase()))
           .findFirst()
           .orElseThrow(
               () ->
                   new IllegalArgumentException(
                       Messages.format("Unsupported report type: {}", reportType)));
   return iniLoader.load(iniFile);
 }
Exemplo n.º 2
0
  // parse a single section
  private static void parseSection(
      PropertySet section,
      String indexNameSuffix,
      FloatingRateType type,
      ImmutableMap.Builder<String, FloatingRateName> builder) {

    // find our names from the RHS of the key/value pairs
    for (String key : section.keys()) {
      builder.put(key, new FloatingRateName(key, section.value(key) + indexNameSuffix, type));
    }
  }