diff --git a/src/main/java/org/apache/commons/lang3/EnumUtils.java b/src/main/java/org/apache/commons/lang3/EnumUtils.java index fc394354c..b4783c7a7 100644 --- a/src/main/java/org/apache/commons/lang3/EnumUtils.java +++ b/src/main/java/org/apache/commons/lang3/EnumUtils.java @@ -339,17 +339,12 @@ public class EnumUtils { * @return the enum, default enum if not found * @since 3.13.0 */ - public static > E getFirstEnumIgnoreCase(final Class enumClass, final String enumName, - final Function stringFunction, final E defaultEnum) { + public static > E getFirstEnumIgnoreCase(final Class enumClass, final String enumName, final Function stringFunction, + final E defaultEnum) { if (enumName == null || !enumClass.isEnum()) { return defaultEnum; } - for (final E each : enumClass.getEnumConstants()) { - if (enumName.equalsIgnoreCase(stringFunction.apply(each))) { - return each; - } - } - return defaultEnum; + return Stream.of(enumClass.getEnumConstants()).filter(e -> enumName.equalsIgnoreCase(stringFunction.apply(e))).findFirst().orElse(defaultEnum); } /**