/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Obtains an instance from the specified name. * <p> * Parsing handles the mixed case form produced by {@link #toString()} and * the upper and lower case variants of the enum constant name. * * @param name the name to parse * @return the type * @throws IllegalArgumentException if the name is not known */ @FromString public static AsciiTableAlignment of(String name) { return NAMES.parse(name); }
/** * 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); }
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_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); }
/** * Obtains an instance from the specified name. * <p> * Parsing handles the mixed case form produced by {@link #toString()} and * the upper and lower case variants of the enum constant name. * * @param name the name to parse * @return the type * @throws IllegalArgumentException if the name is not known */ @FromString public static PaymentOnDefault of(String name) { return NAMES.parse(name); }
/** * 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_twentyOne() { EnumNames<MockEnum> test = EnumNames.of(MockEnum.class); assertEquals(test.parse("TwentyOne"), MockEnum.TWENTY_ONE); assertEquals(test.parse("TWENTYONE"), MockEnum.TWENTY_ONE); assertEquals(test.parse("twentyone"), MockEnum.TWENTY_ONE); assertEquals(test.parse("TWENTY_ONE"), MockEnum.TWENTY_ONE); assertEquals(test.parse("twenty_one"), MockEnum.TWENTY_ONE); }
/** * 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); }
/** * Obtains an instance from the specified name. * <p> * Parsing handles the mixed case form produced by {@link #toString()} and * the upper and lower case variants of the enum constant name. * * @param name the name to parse * @return the type * @throws IllegalArgumentException if the name is not known */ @FromString public static FailureReason of(String name) { return NAMES.parse(name); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Obtains an instance from the specified name. * <p> * Parsing handles the mixed case form produced by {@link #toString()} and * the upper and lower case variants of the enum constant name. * * @param name the name to parse * @return the type * @throws IllegalArgumentException if the name is not known */ @FromString public static EtdSettlementType of(String name) { return NAMES.parse(name); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Obtains an instance from the specified name. * <p> * Parsing handles the mixed case form produced by {@link #toString()} and * the upper and lower case variants of the enum constant name. * * @param name the name to parse * @return the type * @throws IllegalArgumentException if the name is not known */ @FromString public static CurveNodeDateType of(String name) { return NAMES.parse(name); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }
/** * Obtains an instance from the specified name. * <p> * Parsing handles the mixed case form produced by {@link #toString()} and * the upper and lower case variants of the enum constant name. * * @param name the name to parse * @return the type * @throws IllegalArgumentException if the name is not known */ @FromString public static FraDiscountingMethod of(String name) { return NAMES.parse(name); }
/** * Returns the formatted name of the type. * * @return the formatted string representing the type */ @ToString @Override public String toString() { return NAMES.format(this); }