private static IborFixingDepositConvention createByName(String name) { return IborIndex.extendedEnum().find(name) .map(index -> ImmutableIborFixingDepositConvention.of(index)) .orElse(null); }
private static FraConvention createByName(String name) { return IborIndex.extendedEnum().find(name) .map(index -> ImmutableFraConvention.of(index)) .orElse(null); }
@Override public Set<Tenor> getTenors() { if (!type.isIbor()) { return ImmutableSet.of(); } return IborIndex.extendedEnum().lookupAll().values().stream() .filter(index -> index.getName().startsWith(indexName)) .filter(index -> index.isActive()) .map(index -> index.getTenor()) .sorted() .collect(toImmutableSet()); }
/** * Obtains an instance from the specified unique name. * * @param uniqueName the unique name * @return the index * @throws IllegalArgumentException if the name is not known */ @FromString public static IborIndex of(String uniqueName) { ArgChecker.notNull(uniqueName, "uniqueName"); return extendedEnum().lookup(uniqueName); }
@Test(dataProvider = "name") public void test_extendedEnum(IborIndex convention, String name) { ImmutableMap<String, IborIndex> map = IborIndex.extendedEnum().lookupAll(); assertEquals(map.get(name), convention); }
private static boolean knownReference(String refStr) { try { Optional<IborIndex> ibor = IborIndex.extendedEnum().find(refStr); if (ibor.isPresent()) { return true; } else { Optional<FloatingRateName> frName = FloatingRateName.extendedEnum().find(refStr); if (frName.isPresent()) { return true; } else if (refStr.length() == 3) { Currency.of(refStr); // this may throw an exception validating the string return true; } else { return false; } } } catch (RuntimeException ex) { return false; } }
private static Currency parseCurrency(CsvRow row, CurveName reference) { Optional<String> currencyStr = row.findValue(CURRENCY_HEADER); if (currencyStr.isPresent()) { return LoaderUtils.parseCurrency(currencyStr.get()); } String referenceStr = reference.getName().toUpperCase(Locale.ENGLISH); try { Optional<IborIndex> ibor = IborIndex.extendedEnum().find(referenceStr); if (ibor.isPresent()) { return ibor.get().getCurrency(); } else { Optional<FloatingRateName> frName = FloatingRateName.extendedEnum().find(referenceStr); if (frName.isPresent()) { return frName.get().getCurrency(); } else if (referenceStr.length() == 3) { return Currency.of(referenceStr); } else if (referenceStr.length() > 3 && referenceStr.charAt(3) == '-' || referenceStr.charAt(3) == '_') { return LoaderUtils.parseCurrency(referenceStr.substring(0, 3)); } else { // drop out to exception } } } catch (RuntimeException ex) { // drop out to exception } throw new IllegalArgumentException("Unable to parse currency from reference, consider adding a 'Currency' column"); }
public void test_getFloatingRateName() { for (IborIndex index : IborIndex.extendedEnum().lookupAll().values()) { String name = index.getName().substring(0, index.getName().lastIndexOf('-')); assertEquals(index.getFloatingRateName(), FloatingRateName.of(name)); } }
Optional<IborIndex> iborOpt = IborIndex.extendedEnum().find(indexStr); if (iborOpt.isPresent()) { return (Optional) iborOpt;