/** * Loads the available currency pairs. * * @return the map of known currency pairs, where the value is the number of digits in the rate */ static ImmutableMap<CurrencyPair, Integer> loadPairs() { try { IniFile ini = ResourceConfig.combinedIniFile(ResourceConfig.orderedResources(PAIR_INI)); return parsePairs(ini); } catch (RuntimeException ex) { // logging used because this is loaded in a static variable log.severe(Throwables.getStackTraceAsString(ex)); // return an empty instance to avoid ExceptionInInitializerError return ImmutableMap.of(); } }
/** * Loads the available currencies. * * @param loadHistoric whether to load the historic or active currencies * @return the map of known currencies */ static ImmutableMap<String, Currency> loadCurrencies(boolean loadHistoric) { try { IniFile ini = ResourceConfig.combinedIniFile(ResourceConfig.orderedResources(CURRENCY_INI)); return parseCurrencies(ini, loadHistoric); } catch (RuntimeException ex) { // logging used because this is loaded in a static variable log.severe(Throwables.getStackTraceAsString(ex)); // return an empty instance to avoid ExceptionInInitializerError return ImmutableMap.of(); } }
Loader() { ImmutableMap<String, FloatingRateName> names = ImmutableMap.of(); ImmutableMap<Currency, FloatingRateName> iborDefaults = ImmutableMap.of(); ImmutableMap<Currency, FloatingRateName> overnightDefaults = ImmutableMap.of(); try { IniFile ini = ResourceConfig.combinedIniFile(FLOATING_RATE_NAME_INI); names = parseIndices(ini); iborDefaults = parseIborDefaults(ini, names); overnightDefaults = parseOvernightDefaults(ini, names); } catch (RuntimeException ex) { // logging used because this is loaded in a static variable log.severe(Throwables.getStackTraceAsString(ex)); // return an empty instance to avoid ExceptionInInitializerError } this.names = names; this.iborDefaults = iborDefaults; this.overnightDefaults = overnightDefaults; }
IniFile ini = ResourceConfig.combinedIniFile(ResourceConfig.orderedResources(CURRENCY_DATA_INI)); PropertySet section = ini.section("marketConventionPriority"); String list = section.value("ordering");
/** * Returns a combined INI file formed by merging INI files with the specified name. * <p> * This finds the all files with the specified name in the configuration directories. * Each file is loaded, with the result being formed by merging the files into one. * See {@link #combinedIniFile(List)} for more details on the merge process. * * @param resourceName the resource name * @return the resource locators * @throws UncheckedIOException if an IO exception occurs * @throws IllegalStateException if there is a configuration error */ public static IniFile combinedIniFile(String resourceName) { ArgChecker.notNull(resourceName, "resourceName"); return ResourceConfig.combinedIniFile(ResourceConfig.orderedResources(resourceName)); }
/** * Obtains a combined extended enum instance. * <p> * Calling this method loads configuration files to determine which extended enums to combine. * The configuration file has the same simple name as the specified type and is a * {@linkplain IniFile INI file} with the suffix '.ini'. * * @param <R> the type of the enum * @param type the type to load * @return the extended enum */ public static <R extends Named> CombinedExtendedEnum<R> of(Class<R> type) { try { // load all matching files String name = type.getSimpleName() + ".ini"; IniFile config = ResourceConfig.combinedIniFile(name); // parse files ImmutableList<ExtendedEnum<? extends R>> children = parseChildren(config, type); log.fine(() -> "Loaded combined extended enum: " + name + ", providers: " + children); return new CombinedExtendedEnum<>(type, children); } catch (RuntimeException ex) { // logging used because this is loaded in a static variable log.severe("Failed to load CombinedExtendedEnum for " + type + ": " + Throwables.getStackTraceAsString(ex)); // return an empty instance to avoid ExceptionInInitializerError return new CombinedExtendedEnum<>(type, ImmutableList.of()); } }
IniFile config = ResourceConfig.combinedIniFile(name);
public void test_ofChained_chainToNowhere() { IniFile test = ResourceConfig.combinedIniFile("TestChain3.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "x", "b", "y"); assertEquals(test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1))); }
public void test_ofChained_chainNextFileFalse() { IniFile test = ResourceConfig.combinedIniFile("TestChain2.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "z"); Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n"); assertEquals( test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1), "two", PropertySet.of(keyValues2))); }
public void test_ofChained_chainRemoveSections() { IniFile test = ResourceConfig.combinedIniFile("TestChain5.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "a"); Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n", "o", "z"); assertEquals( test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1), "two", PropertySet.of(keyValues2))); }
public void test_ofChained_chainNextFileTrue() { IniFile test = ResourceConfig.combinedIniFile("TestChain1.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "z", "b", "y"); Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n"); assertEquals( test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1), "two", PropertySet.of(keyValues2))); }
public void test_ofChained_autoChain() { IniFile test = ResourceConfig.combinedIniFile("TestChain4.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "z", "b", "y"); Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n"); assertEquals( test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1), "two", PropertySet.of(keyValues2))); }