@@ -192,10 +192,10 @@ public static <E extends Enum<E>> long[] generateBitVectors(final Class<E> enumC
192192 * <p>This method differs from {@link Enum#valueOf} in that it does not throw an exception
193193 * for an invalid enum name.</p>
194194 *
195- * @param <E> the type of the enumeration
196- * @param enumClass the class of the enum to query, not null
197- * @param enumName the enum name, null returns null
198- * @return the enum, null if not found
195+ * @param <E> the type of the enumeration.
196+ * @param enumClass the class of the enum to query, not null.
197+ * @param enumName the enum name, null returns null.
198+ * @return the enum, null if not found.
199199 */
200200 public static <E extends Enum <E >> E getEnum (final Class <E > enumClass , final String enumName ) {
201201 return getEnum (enumClass , enumName , null );
@@ -207,20 +207,20 @@ public static <E extends Enum<E>> E getEnum(final Class<E> enumClass, final Stri
207207 * <p>This method differs from {@link Enum#valueOf} in that it does not throw an exception
208208 * for an invalid enum name.</p>
209209 *
210- * @param <E> the type of the enumeration
211- * @param enumClass the class of the enum to query, not null
212- * @param enumName the enum name, null returns default enum
213- * @param defaultEnum the default enum
214- * @return the enum, default enum if not found
210+ * @param <E> the type of the enumeration.
211+ * @param enumClass the class of the enum to query, null returns default enum.
212+ * @param enumName the enum name, null returns default enum.
213+ * @param defaultEnum the default enum.
214+ * @return the enum, default enum if not found.
215215 * @since 3.10
216216 */
217217 public static <E extends Enum <E >> E getEnum (final Class <E > enumClass , final String enumName , final E defaultEnum ) {
218- if (enumName == null ) {
218+ if (enumClass == null || enumName == null ) {
219219 return defaultEnum ;
220220 }
221221 try {
222222 return Enum .valueOf (enumClass , enumName );
223- } catch (final IllegalArgumentException ex ) {
223+ } catch (final IllegalArgumentException e ) {
224224 return defaultEnum ;
225225 }
226226 }
@@ -320,10 +320,8 @@ public static <E extends Enum<E>, K> Map<K, E> getEnumMap(final Class<E> enumCla
320320 * @return the enum, default enum if not found.
321321 * @since 3.13.0
322322 */
323- public static <E extends Enum <E >> E getEnumSystemProperty (final Class <E > enumClass , final String propName ,
324- final E defaultEnum ) {
325- return enumClass == null || propName == null ? defaultEnum
326- : getEnum (enumClass , SystemProperties .getProperty (propName ), defaultEnum );
323+ public static <E extends Enum <E >> E getEnumSystemProperty (final Class <E > enumClass , final String propName , final E defaultEnum ) {
324+ return getEnum (enumClass , SystemProperties .getProperty (propName ), defaultEnum );
327325 }
328326
329327 /**
@@ -365,11 +363,11 @@ public static <E extends Enum<E>> E getFirstEnum(final Class<E> enumClass, final
365363 */
366364 public static <E extends Enum <E >> E getFirstEnumIgnoreCase (final Class <E > enumClass , final String enumName , final Function <E , String > stringFunction ,
367365 final E defaultEnum ) {
368- if (enumName == null || !enumClass .isEnum ()) {
369- return defaultEnum ;
370- }
371- return stream (enumClass ).filter (e -> enumName .equalsIgnoreCase (stringFunction .apply (e ))).findFirst ().orElse (defaultEnum );
366+ if (enumName == null || !enumClass .isEnum ()) {
367+ return defaultEnum ;
372368 }
369+ return stream (enumClass ).filter (e -> enumName .equalsIgnoreCase (stringFunction .apply (e ))).findFirst ().orElse (defaultEnum );
370+ }
373371
374372 private static <E extends Enum <E >> boolean isEnum (final Class <E > enumClass ) {
375373 return enumClass != null && !enumClass .isEnum ();
@@ -378,13 +376,14 @@ private static <E extends Enum<E>> boolean isEnum(final Class<E> enumClass) {
378376 /**
379377 * Checks if the specified name is a valid enum for the class.
380378 *
381- * <p>This method differs from {@link Enum#valueOf} in that it checks if the name is
382- * a valid enum without needing to catch the exception.</p>
379+ * <p>
380+ * This method differs from {@link Enum#valueOf} in that it checks if the name is a valid enum without needing to catch the exception.
381+ * </p>
383382 *
384- * @param <E> the type of the enumeration
385- * @param enumClass the class of the enum to query, not null
386- * @param enumName the enum name, null returns false
387- * @return true if the enum name is valid, otherwise false
383+ * @param <E> the type of the enumeration.
384+ * @param enumClass the class of the enum to query, null returns false.
385+ * @param enumName the enum name, null returns false.
386+ * @return true if the enum name is valid, otherwise false.
388387 */
389388 public static <E extends Enum <E >> boolean isValidEnum (final Class <E > enumClass , final String enumName ) {
390389 return getEnum (enumClass , enumName ) != null ;
@@ -393,14 +392,15 @@ public static <E extends Enum<E>> boolean isValidEnum(final Class<E> enumClass,
393392 /**
394393 * Checks if the specified name is a valid enum for the class.
395394 *
396- * <p>This method differs from {@link Enum#valueOf} in that it checks if the name is
397- * a valid enum without needing to catch the exception
398- * and performs case insensitive matching of the name.</p>
395+ * <p>
396+ * This method differs from {@link Enum#valueOf} in that it checks if the name is a valid enum without needing to catch the exception and performs case
397+ * insensitive matching of the name.
398+ * </p>
399399 *
400- * @param <E> the type of the enumeration
401- * @param enumClass the class of the enum to query, not null
402- * @param enumName the enum name, null returns false
403- * @return true if the enum name is valid, otherwise false
400+ * @param <E> the type of the enumeration.
401+ * @param enumClass the class of the enum to query, null returns false.
402+ * @param enumName the enum name, null returns false.
403+ * @return true if the enum name is valid, otherwise false.
404404 * @since 3.8
405405 */
406406 public static <E extends Enum <E >> boolean isValidEnumIgnoreCase (final Class <E > enumClass , final String enumName ) {
0 commit comments