[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Enum#valueOf implementation
From: |
Ewout Prangsma |
Subject: |
[cp-patches] Enum#valueOf implementation |
Date: |
Fri, 22 Jul 2005 19:53:03 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
I've implemented java.lang.Enum#valueOf in the generics branch.
Can someone with CVS access verify and commit this.
PS. My FSF paperwork is all done.
Thanks
Ewout
@SuppressWarnings("unchecked")
public static <S extends Enum<S>> Enum valueOf(Class<S> etype, String s) {
if (etype == null || s == null)
throw new NullPointerException();
try {
return (S) etype.getDeclaredField(s).get(null);
} catch (NoSuchFieldException exception) {
throw new IllegalArgumentException(s);
} catch (IllegalAccessException exception) {
throw new Error("Unable to access Enum class");
}
}
- [cp-patches] Enum#valueOf implementation,
Ewout Prangsma <=