StringExt { public static <E extends Enum<E>> List<E> parseEnumListIgnoreCase(String enumNames, Class<E> enumType) { return parseEnumListIgnoreCase(enumNames, enumType, null); } private  StringExt(); static boolean isNotEmpty(String s); static boolean isEmpty(String s); static String safeTrim(String s); static String nonNull(String value); static String takeUntil(String value, String endMarker); static void applyIfNonEmpty(String value, Consumer<String> consumer); static void runIfEmpty(String value, Runnable action); static void trimAndApplyIfNonEmpty(String value, Consumer<String> consumer); static String concatenate(Collection<String> stringCollection, String delimiter); static String concatenate(T[] array, String delimiter, Function<T, String> mapping); static String concatenate(Object[] array, String delimiter); static String concatenate(E[] array, String delimiter); static String concatenate(Class<E> enumType, String delimiter, Function<E, Boolean> filter); static String getNonEmptyOrDefault(String value, String defaultValue); static Optional<String> firstNonEmpty(String... values); static List<String> trim(List<String> list); static Pattern getCommaSeparator(); static Pattern getDotSeparator(); static Pattern getSemicolonSeparator(); static List<String> splitByComma(String value); static Set<String> splitByCommaIntoSet(String value); static List<String> splitByDot(String value); static E parseEnumIgnoreCase(String enumName, Class<E> enumType); static List<E> parseEnumListIgnoreCase(String enumNames, Class<E> enumType); static List<E> parseEnumListIgnoreCase(String enumNames, Class<E> enumType, Function<String, List<E>> groupings); static Map<String, A> parseKeyValueList(String text, Pattern entrySeparator, Pattern pairSeparator,
                                                       BiFunction<A, String, A> accumulator); static Map<String, String> parseKeyValueList(String text); static Map<String, Set<String>> parseKeyValuesList(String text); static boolean isAsciiLetter(char c); static boolean isAsciiDigit(char c); static boolean isAsciiLetterOrDigit(char c); static String removeNonAlphanumeric(String text); static int indexOf(Pattern pattern, String text); static String doubleQuotes(String text); static String removeSurroundingQuotes(String text); static String appendToEndIfMissing(String text, String value); static String startWithLowercase(String text); static Optional<Integer> parseInt(String s); static Optional<Long> parseLong(String s); static Optional<Double> parseDouble(String s); static Optional<List<Duration>> parseDurationMsList(String s); static String gzipAndBase64Encode(String s); static Either<String, IllegalArgumentException> nameFromJavaBeanGetter(String getterName); final static Pattern COMMA_SPLIT_RE; final static Pattern DOT_SPLIT_RE; final static Pattern SEMICOLON_SPLIT_RE; final static Pattern COLON_SPLIT_RE; final static Pattern EQUAL_SPLIT_RE; }
@Test public void testParseEnumListIgnoreCase() { assertThat(parseEnumListIgnoreCase("", EnumValue.class)).isEmpty(); assertThat(parseEnumListIgnoreCase(" ", EnumValue.class)).isEmpty(); assertThat(parseEnumListIgnoreCase("a , B", EnumValue.class)).contains(EnumValue.A, EnumValue.B); Map<String, List<EnumValue>> grouping = singletonMap("ab", asList(EnumValue.C, EnumValue.D)); assertThat(parseEnumListIgnoreCase("a , B, AB", EnumValue.class, grouping::get)).contains(EnumValue.A, EnumValue.B); try { parseEnumListIgnoreCase("a , bb", EnumValue.class); fail("Expected to fail during parsing invalid enum value"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).contains("bb"); } }