/** * Writes the curve group in a CSV format to a file. * * @param file the file * @param groups the curve groups */ public static void writeCurveGroup(File file, RatesCurveGroup... groups) { try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) { writeCurveGroup(writer, groups); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
/** * Writes the curve group in a CSV format to an appendable. * * @param underlying the underlying appendable destination * @param groups the curve groups */ public static void writeCurveGroup(Appendable underlying, RatesCurveGroup... groups) { CsvOutput csv = CsvOutput.standard(underlying); csv.writeLine(HEADERS); for (RatesCurveGroup group : groups) { writeCurveGroup(csv, group); } }
public void test_writeCurveGroup() { List<RatesCurveGroup> curveGroups = RatesCurvesCsvLoader.load( CURVE_DATE, ResourceLocator.of(GROUPS_1), ResourceLocator.of(SETTINGS_1), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); Appendable underlying = new StringBuilder(); RatesCurveGroupDefinitionCsvLoader.writeCurveGroup(underlying, curveGroups.get(0)); String created = underlying.toString(); String expected = "Group Name,Curve Type,Reference,Curve Name" + System.lineSeparator() + "Default,discount,USD,USD-Disc" + System.lineSeparator() + "Default,forward,USD-LIBOR-3M,USD-3ML" + System.lineSeparator(); assertEquals(created, expected); }