Created
August 18, 2020 16:28
-
-
Save doom369/c3f488c0f2be31d75e7b565e2597638b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T extends Enum<T>> T valueOf(Class<T> enumType, | |
String name) { | |
T result = enumType.enumConstantDirectory().get(name); | |
if (result != null) | |
return result; | |
if (name == null) | |
throw new NullPointerException("Name is null"); | |
throw new IllegalArgumentException( | |
"No enum constant " + enumType.getCanonicalName() + "." + name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment