You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stephen Colebourne (JIRA)" <ji...@apache.org> on 2009/10/27 01:53:59 UTC

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

    [ https://issues.apache.org/jira/browse/LANG-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770322#action_12770322 ] 

Stephen Colebourne commented on LANG-290:
-----------------------------------------

Added getEnumList(), isEnum(), getEnum(), and fixed bug with generics of getEnumMap().

commit -m "LANG-290 - Add more enum utility methods" /dev/commons/lang/src/java/org/apache/commons/lang/EnumUtils.java /dev/commons/lang/src/test/org/apache/commons/lang/EnumUtilsTest.java
    Sending        /dev/commons/lang/src/java/org/apache/commons/lang/EnumUtils.java
    Sending        /dev/commons/lang/src/test/org/apache/commons/lang/EnumUtilsTest.java
    Transmitting file data ...
    Committed revision 830038.

> EnumUtils for JDK 5.0
> ---------------------
>
>                 Key: LANG-290
>                 URL: https://issues.apache.org/jira/browse/LANG-290
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 2.2
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>
> 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.
-
You can reply to this email to add a comment to the issue online.