You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Henri Yandell (JIRA)" <ji...@apache.org> on 2006/10/24 23:14:19 UTC

[jira] Commented: (LANG-290) EnumUtils for JDK 5.0

    [ http://issues.apache.org/jira/browse/LANG-290?page=comments#action_12444516 ] 
            
Henri Yandell commented on LANG-290:
------------------------------------

Should go in org.apache.commons.lang.EnumUtils I think - with suitable javadoc to explain this is for 5.0 and that the enums subpackage is for legacy 1.2->1.4.

> EnumUtils for JDK 5.0
> ---------------------
>
>                 Key: LANG-290
>                 URL: http://issues.apache.org/jira/browse/LANG-290
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 2.2
>            Reporter: Henri Yandell
>             Fix For: JDK 5.0 features
>
>
> Below is an EnumUtils for JDK 1.5. It's also found in the enums.EnumUtils javadoc:
>  import java.util.*;
>  public class EnumUtils {
>    public static Enum getEnum(Class enumClass, String token) {
>      return Enum.valueOf(enumClass, token);
>    }
>    public static Map getEnumMap(Class enumClass) {
>      HashMap map = new HashMap();
>      Iterator itr = EnumUtils.iterator(enumClass);
>      while(itr.hasNext()) {
>        Enum enm = (Enum) itr.next();
>        map.put( enm.name(), enm );
>      }
>      return map;
>    }
>                   
>    public static List getEnumList(Class enumClass) {
>      return new ArrayList( EnumSet.allOf(enumClass) );
>    }
>                       
>    public static Iterator iterator(Class enumClass) {
>      return EnumUtils.getEnumList(enumClass).iterator();
>    }
>  }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org