/** * Obtains an instance from the specified unique name. * * @param uniqueName the unique name * @return the convention * @throws IllegalArgumentException if the name is not known */ @FromString public static IborFixingDepositConvention of(String uniqueName) { ArgChecker.notNull(uniqueName, "uniqueName"); return extendedEnum().lookup(uniqueName); }
/** * Obtains a convention based on the specified index. * <p> * This uses the index name to find the matching convention. * By default, this will always return a convention, however configuration may be added * to restrict the conventions that are registered. * * @param index the index, from which the index name is used to find the matching convention * @return the convention * @throws IllegalArgumentException if no convention is registered for the index */ public static IborFixingDepositConvention of(IborIndex index) { ArgChecker.notNull(index, "index"); return extendedEnum().lookup(index.getName()); }
@Test(dataProvider = "name") public void test_extendedEnum(IborFixingDepositConvention convention, String name) { IborFixingDepositConvention.of(name); // ensures map is populated ImmutableMap<String, IborFixingDepositConvention> map = IborFixingDepositConvention.extendedEnum().lookupAll(); assertEquals(map.get(name), convention); }