/** * Creates an instance where the {@code toString} method is written manually. * <p> * The {@code toString} method is called to extract the correct formatted string. * * @param <T> the type of the enum * @param enumType the type of the enum * @return the names instance */ public static <T extends Enum<T> & NamedEnum> EnumNames<T> ofManualToString(Class<T> enumType) { return new EnumNames<>(enumType, true); }
/** * Converts an FpML business day convention string to a {@code BusinessDayConvention}. * * @param fmplBusinessDayConventionName the business day convention name used by FpML * @return the business day convention * @throws IllegalArgumentException if the business day convention is not known */ public BusinessDayConvention convertBusinessDayConvention(String fmplBusinessDayConventionName) { return BusinessDayConvention.extendedEnum().externalNames(ENUM_FPML).lookup(fmplBusinessDayConventionName); }
public static ExtendedEnum<SampleNamed> extendedEnum() { return ExtendedEnum.of(SampleNamed.class); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
public void test_parse_fooBar() { EnumNames<MockEnum> test = EnumNames.of(MockEnum.class); assertEquals(test.parse("Foobar"), MockEnum.FooBar); assertEquals(test.parse("FOOBAR"), MockEnum.FooBar); assertEquals(test.parse("foobar"), MockEnum.FooBar); assertEquals(test.parse("FooBar"), MockEnum.FooBar); }
public void test_format() { EnumNames<MockEnum> test = EnumNames.of(MockEnum.class); assertEquals(test.format(MockEnum.ONE), "One"); assertEquals(test.format(MockEnum.TWENTY_ONE), "TwentyOne"); assertEquals(test.format(MockEnum.FooBar), "Foobar"); assertEquals(test.format(MockEnum.WOO_BAR_WAA), "WooBarWaa"); }
public void test_lookup() { assertEquals(UberNamed.of("Standard"), SampleNameds.STANDARD); assertEquals(UberNamed.of("More"), MoreSampleNameds.MORE); CombinedExtendedEnum<UberNamed> combined = CombinedExtendedEnum.of(UberNamed.class); assertEquals(combined.find("Rubbish"), Optional.empty()); assertThrows(IllegalArgumentException.class, () -> combined.lookup("Rubbish")); assertEquals(combined.toString(), "CombinedExtendedEnum[UberNamed]"); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
public void test_parse_wooBarWaa() { EnumNames<MockEnum> test = EnumNames.of(MockEnum.class); assertEquals(test.parse("WooBarWaa"), MockEnum.WOO_BAR_WAA); assertEquals(test.parse("WOOBARWAA"), MockEnum.WOO_BAR_WAA); assertEquals(test.parse("woobarwaa"), MockEnum.WOO_BAR_WAA); assertEquals(test.parse("WOO_BAR_WAA"), MockEnum.WOO_BAR_WAA); assertEquals(test.parse("woo_bar_waa"), MockEnum.WOO_BAR_WAA); }
/** * Converts an FpML roll convention string to a {@code RollConvention}. * * @param fmplRollConventionName the roll convention name used by FpML * @return the roll convention * @throws IllegalArgumentException if the roll convention is not known */ public RollConvention convertRollConvention(String fmplRollConventionName) { return RollConvention.extendedEnum().externalNames(ENUM_FPML).lookup(fmplRollConventionName); }
/** * Creates an instance deriving the formatted string from the enum constant name. * * @param <T> the type of the enum * @param enumType the type of the enum * @return the names instance */ public static <T extends Enum<T> & NamedEnum> EnumNames<T> of(Class<T> enumType) { return new EnumNames<>(enumType, false); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Converts an FpML day count string to a {@code DayCount}. * * @param fpmlDayCountName the day count name used by FpML * @return the day count * @throws IllegalArgumentException if the day count is not known */ public DayCount convertDayCount(String fpmlDayCountName) { return DayCount.extendedEnum().externalNames(ENUM_FPML).lookup(fpmlDayCountName); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }