commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r534264 - in /jakarta/commons/proper/lang/branches/LangTwo-1.x/src: java/org/apache/commons/lang2/ java/org/apache/commons/lang2/enum/ java/org/apache/commons/lang2/enums/ test/org/apache/commons/lang2/ test/org/apache/commons/lang2/enum/ t...
Date Tue, 01 May 2007 22:36:09 GMT
Author: bayard
Date: Tue May  1 15:36:08 2007
New Revision: 534264

URL: http://svn.apache.org/viewvc?view=rev&rev=534264
Log:
Killing the enum/enums packages and adding a proposed EnumUtils class that contains the previous
functionality wrapped around java.lang.Enum

Added:
    jakarta/commons/proper/lang/branches/LangTwo-1.x/src/java/org/apache/commons/lang2/EnumUtils.java
Removed:
    jakarta/commons/proper/lang/branches/LangTwo-1.x/src/java/org/apache/commons/lang2/enum/
    jakarta/commons/proper/lang/branches/LangTwo-1.x/src/java/org/apache/commons/lang2/enums/
    jakarta/commons/proper/lang/branches/LangTwo-1.x/src/test/org/apache/commons/lang2/enum/
    jakarta/commons/proper/lang/branches/LangTwo-1.x/src/test/org/apache/commons/lang2/enums/
Modified:
    jakarta/commons/proper/lang/branches/LangTwo-1.x/src/test/org/apache/commons/lang2/AllLangTestSuite.java

Added: jakarta/commons/proper/lang/branches/LangTwo-1.x/src/java/org/apache/commons/lang2/EnumUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/branches/LangTwo-1.x/src/java/org/apache/commons/lang2/EnumUtils.java?view=auto&rev=534264
==============================================================================
--- jakarta/commons/proper/lang/branches/LangTwo-1.x/src/java/org/apache/commons/lang2/EnumUtils.java
(added)
+++ jakarta/commons/proper/lang/branches/LangTwo-1.x/src/java/org/apache/commons/lang2/EnumUtils.java
Tue May  1 15:36:08 2007
@@ -0,0 +1,39 @@
+package org.apache.commons.lang2;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility class for java.lang.Enum as found in Java 5.
+ *
+ * Lang1's EnumUtils.getEnum(Class,String) should be directly replaced by java.lang.Enum.valueOf(Class,String)
+ * Lang1's EnumUtils.getEnumList(Class) is now the deprecated EnumUtils.asList(Class)
+ */
+public class EnumUtils {
+
+    public static <E extends Enum<E>> Map<String, E> getEnumMap(Class<E>
enumClass) {
+        HashMap map = new HashMap<String, E>();
+        Iterator itr = EnumSet.allOf(enumClass).iterator();
+        while(itr.hasNext()) {
+          Enum enm = (Enum) itr.next();
+          map.put( enm.name(), enm );
+        }
+        return map;
+    }
+                  
+    /**
+     * @deprecated as coders should move to java.util.EnumSet.allOf(Class)
+     */
+    public static <E extends Enum<E>> List<E> asList(Class<E> enumClass)
{
+        return new ArrayList<E>( EnumSet.allOf(enumClass) );
+    }
+                      
+    public static <E extends Enum<E>> Iterator<E> iterator(Class<E>
enumClass) {
+        return EnumSet.allOf(enumClass).iterator();
+    }
+
+}

Modified: jakarta/commons/proper/lang/branches/LangTwo-1.x/src/test/org/apache/commons/lang2/AllLangTestSuite.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/branches/LangTwo-1.x/src/test/org/apache/commons/lang2/AllLangTestSuite.java?view=diff&rev=534264&r1=534263&r2=534264
==============================================================================
--- jakarta/commons/proper/lang/branches/LangTwo-1.x/src/test/org/apache/commons/lang2/AllLangTestSuite.java
(original)
+++ jakarta/commons/proper/lang/branches/LangTwo-1.x/src/test/org/apache/commons/lang2/AllLangTestSuite.java
Tue May  1 15:36:08 2007
@@ -22,7 +22,6 @@
 import junit.textui.TestRunner;
 
 import org.apache.commons.lang2.builder.BuilderTestSuite;
-import org.apache.commons.lang2.enums.EnumTestSuite;
 import org.apache.commons.lang2.exception.ExceptionTestSuite;
 import org.apache.commons.lang2.math.MathTestSuite;
 import org.apache.commons.lang2.mutable.MutableTestSuite;
@@ -59,8 +58,6 @@
         suite.setName("Commons-Lang (all) Tests");
         suite.addTest(LangTestSuite.suite());
         suite.addTest(BuilderTestSuite.suite());
-        suite.addTest(EnumTestSuite.suite());
-        suite.addTest(org.apache.commons.lang2.enum.EnumTestSuite.suite());
         suite.addTest(ExceptionTestSuite.suite());
         suite.addTest(MathTestSuite.suite());
         suite.addTest(MutableTestSuite.suite());



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


Mime
View raw message