/** * Loads one or more CSV format FX rate files. * <p> * All dates that are found will be returned. * <p> * If the files contain a duplicate entry an exception will be thrown. * * @param resources the CSV resources * @return the loaded FX rates, mapped by {@link LocalDate} and {@linkplain FxRateId rate ID} * @throws IllegalArgumentException if the files contain a duplicate entry */ public static ImmutableMap<LocalDate, ImmutableMap<FxRateId, FxRate>> loadAllDates( Collection<ResourceLocator> resources) { Collection<CharSource> charSources = resources.stream().map(r -> r.getCharSource()).collect(toList()); return parse(d -> true, charSources); }
/** * Loads one or more CSV format FX rate files for a set of dates. * <p> * Only those rates that match one of the specified dates will be loaded. * <p> * If the files contain a duplicate entry an exception will be thrown. * * @param marketDataDates the dates to load * @param resources the CSV resources * @return the loaded FX rates, mapped by {@link LocalDate} and {@linkplain FxRateId rate ID} * @throws IllegalArgumentException if the files contain a duplicate entry */ public static ImmutableMap<LocalDate, ImmutableMap<FxRateId, FxRate>> load( Set<LocalDate> marketDataDates, Collection<ResourceLocator> resources) { Collection<CharSource> charSources = resources.stream().map(r -> r.getCharSource()).collect(toList()); return parse(d -> marketDataDates.contains(d), charSources); }
/** * Loads one or more CSV format FX rate files for a specific date. * <p> * Only those rates that match the specified date will be loaded. * <p> * If the files contain a duplicate entry an exception will be thrown. * * @param marketDataDate the date to load * @param resources the CSV resources * @return the loaded FX rates, mapped by {@linkplain FxRateId rate ID} * @throws IllegalArgumentException if the files contain a duplicate entry */ public static ImmutableMap<FxRateId, FxRate> load(LocalDate marketDataDate, Collection<ResourceLocator> resources) { Collection<CharSource> charSources = resources.stream().map(r -> r.getCharSource()).collect(toList()); return parse(d -> marketDataDate.equals(d), charSources).getOrDefault(marketDataDate, ImmutableMap.of()); }