Sort members.
This commit is contained in:
parent
7f9472e898
commit
70abafc95d
|
@ -258,33 +258,6 @@ public class EnumUtils {
|
||||||
return getFirstEnumIgnoreCase(enumClass, enumName, Enum::name, defaultEnum);
|
return getFirstEnumIgnoreCase(enumClass, enumName, Enum::name, defaultEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Gets the enum for the class, returning {@code defaultEnum} if not found.</p>
|
|
||||||
*
|
|
||||||
* <p>This method differs from {@link Enum#valueOf} in that it does not throw an exception
|
|
||||||
* for an invalid enum name and performs case insensitive matching of the name.</p>
|
|
||||||
*
|
|
||||||
* @param <E> the type of the enumeration
|
|
||||||
* @param enumClass the class of the enum to query, not null
|
|
||||||
* @param enumName the enum name, null returns default enum
|
|
||||||
* @param stringFunction the function that gets the string for an enum for comparison to {@code enumName}.
|
|
||||||
* @param defaultEnum the default enum
|
|
||||||
* @return the enum, default enum if not found
|
|
||||||
* @since 3.13.0
|
|
||||||
*/
|
|
||||||
public static <E extends Enum<E>> E getFirstEnumIgnoreCase(final Class<E> enumClass, final String enumName,
|
|
||||||
final Function<E, String> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Gets the {@code List} of enums.</p>
|
* <p>Gets the {@code List} of enums.</p>
|
||||||
*
|
*
|
||||||
|
@ -337,6 +310,33 @@ public class EnumUtils {
|
||||||
: getEnum(enumClass, System.getProperty(propName), defaultEnum);
|
: getEnum(enumClass, System.getProperty(propName), defaultEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Gets the enum for the class, returning {@code defaultEnum} if not found.</p>
|
||||||
|
*
|
||||||
|
* <p>This method differs from {@link Enum#valueOf} in that it does not throw an exception
|
||||||
|
* for an invalid enum name and performs case insensitive matching of the name.</p>
|
||||||
|
*
|
||||||
|
* @param <E> the type of the enumeration
|
||||||
|
* @param enumClass the class of the enum to query, not null
|
||||||
|
* @param enumName the enum name, null returns default enum
|
||||||
|
* @param stringFunction the function that gets the string for an enum for comparison to {@code enumName}.
|
||||||
|
* @param defaultEnum the default enum
|
||||||
|
* @return the enum, default enum if not found
|
||||||
|
* @since 3.13.0
|
||||||
|
*/
|
||||||
|
public static <E extends Enum<E>> E getFirstEnumIgnoreCase(final Class<E> enumClass, final String enumName,
|
||||||
|
final Function<E, String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Checks if the specified name is a valid enum for the class.</p>
|
* <p>Checks if the specified name is a valid enum for the class.</p>
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue