java.lang.Object
org.kohsuke.github.internal.EnumUtils
Utils for Enums.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Enum<E>>
EgetEnumOrDefault
(Class<E> enumClass, String value, E defaultEnum) Returns an enum value matching the value if found,defaultEnum
if the value is null or cannot be matched to a value of the enum.static <E extends Enum<E>>
EgetNullableEnumOrDefault
(Class<E> enumClass, String value, E defaultEnum) Returns an enum value matching the value if found, null if the value is null anddefaultEnum
if the value cannot be matched to a value of the enum.
-
Method Details
-
getNullableEnumOrDefault
public static <E extends Enum<E>> E getNullableEnumOrDefault(Class<E> enumClass, String value, E defaultEnum) Returns an enum value matching the value if found, null if the value is null anddefaultEnum
if the value cannot be matched to a value of the enum.The value is converted to uppercase before being matched to the enum values.
- Type Parameters:
E
- the type of the enum- Parameters:
enumClass
- the type of the enumvalue
- the value to interpretdefaultEnum
- the default enum value if the value doesn't match one of the enum value- Returns:
- an enum value or null
-
getEnumOrDefault
public static <E extends Enum<E>> E getEnumOrDefault(Class<E> enumClass, String value, E defaultEnum) Returns an enum value matching the value if found,defaultEnum
if the value is null or cannot be matched to a value of the enum.- Type Parameters:
E
- the type of the enum- Parameters:
enumClass
- the type of the enumvalue
- the value to interpretdefaultEnum
- the default enum value if the value doesn't match one of the enum value- Returns:
- an enum value
-