JDK-6234270 : Class Enum needs a function like Enum getEnumFor(int)
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-03-01
  • Updated: 2015-03-25
  • Resolved: 2005-03-01
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
 
one needs a function that can translate from a <int> into the particular enum value...


JUSTIFICATION :
when one is developing one the wire protocols... one needs to be able to translate from a one the wire <int> back to a enum value... currently the only way to do that is to have
a switch statement

switch( aValue )
  {
   case 0:
       {
       theENUM = ENUM_0;
        break;
       }// end case 0

one has to do that for every Enum which makes them hard to work with...
###@###.### 2005-03-01 11:53:22 GMT

Comments
EVALUATION Use the static method of any enum class: MyEnum.values()[aValue] The method isn't defined in java.lang.Enum, but you can see it in the javadoc of any enum class. ###@###.### 2005-03-01 17:17:47 GMT
01-03-2005