Issue Details (XML | Word | Printable)

Key: LANG-258
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Ralf Hauser
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Lang

Enum JavaDoc: 1) outline 5.0 native Enum migration 2) warn not to use the switch() , 3) point out approaches for persistence and gui

Created: 21/May/06 12:31 AM   Updated: 06/Feb/07 11:47 PM
Return to search
Component/s: None
Affects Version/s: 2.1
Fix Version/s: 2.3

Time Tracking:
Not Specified

Environment: all
Issue Links:
Reference
 

Resolution Date: 20/Oct/06 10:37 PM


 Description  « Hide
http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/enums/Enum.html is great!

Now that Jdk5.0 has its own approach for type-safe enums, would it be great to provide a few sentences

  • whether they simply should co-habit?
  • how one would best migrate?
  • where the concepts are different

Also, it would be great to provide some hints how to work on the with a MVC/GUI framework - see SB-20.

also, http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/enums/ValuedEnum.html has a minor typo

it says "doSomething(JavaVersion", but should say "doSomething(JavaVersionEnum"

also, it should contain a big warning that by using switch(), one opens up for type-unsafety!



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Ralf Hauser added a comment - 21/May/06 12:59 AM
oops, referencing attempt 2: http://issues.apache.org/struts/browse/SB-20

Henri Yandell made changes - 23/May/06 11:22 PM
Field Original Value New Value
Fix Version/s 2.2 [ 12311702 ]
Henri Yandell added a comment - 08/Jun/06 03:42 PM
In an effort to get 2.2 out sooner rather than later, I'm assiging all the Enum issues to 2.3. There's been no work on them currently and might be best to focus on them in a 2.3 release instead of trying to squeeze them into the 2.2 release.

Hopefully this will keep the 2.3 release scope pretty tight.


Henri Yandell made changes - 08/Jun/06 03:42 PM
Fix Version/s 2.3 [ 12311948 ]
Fix Version/s 2.2 [ 12311702 ]
Henri Yandell added a comment - 10/Sep/06 08:01 AM
Fixed the doSomething javado typo in r441929. Will go with 2.2.

Repository Revision Date User Message
ASF #441929 Sun Sep 10 08:04:17 UTC 2006 bayard Fixed javadoc typo as mentioned in #LANG-258
Files Changed
MODIFY /jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/enum/ValuedEnum.java
MODIFY /jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/enums/ValuedEnum.java

Henri Yandell added a comment - 20/Oct/06 10:02 PM
svn ci -m "Adding note that using switch is not type-safe" src/java/org/apache/commons/lang/enums/ValuedEnum.java

Sending src/java/org/apache/commons/lang/enums/ValuedEnum.java
Transmitting file data .
Committed revision 466275.


Henri Yandell added a comment - 20/Oct/06 10:06 PM
SB-20 => https://issues.apache.org/struts/browse/STR-2943

If someone with experience in using the Enum classes in MVC/GUI scenarios has comments, it'd be great to get them in the user guide/javadoc; but in the meantime I'm not going to do anything with respect to that part of the above.


Henri Yandell added a comment - 20/Oct/06 10:36 PM
svn ci -m "Taking a stab at adding information on a Lang and Java 5.0 enum comparison" src/java/org/apache/commons/lang/enums/Enum.java

Sending src/java/org/apache/commons/lang/enums/Enum.java
Transmitting file data .
Committed revision 466285.

Namely:

  • <h4>Lang Enums and Java 5.0 Enums</h4>
  • <p>Enums were added to Java in Java 5.0. The main differences between Lang's
  • implementation and the new official JDK implementation are: </p>
  • <ul>
  • <li>The standard Enum is a not just a superclass, but is a type baked into the
  • language. </li>
  • <li>The standard Enum does not support extension, so the standard methods that
  • are provided in the Lang enum are not available. </li>
  • <li>Lang mandates a String name, whereas the standard Enum uses the class
  • name as its name. getName() changes to name(). </li>
  • </ul>
  • <p>Generally people should use the standard Enum. Migrating from the Lang
  • enum to the standard Enum is not as easy as it might be due to the lack of
  • class inheritence in standard Enums. This means that it's not possible
  • to provide a 'super-enum' which could provide the same utility methods
  • that the Lang enum does. The following utility class is a Java 5.0
  • version of our EnumUtils class and provides those utility methods. </p>
    *
  • <pre>
  • 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(); * }
  • }
  • </pre>

Henri Yandell added a comment - 20/Oct/06 10:37 PM
All of the parts of this issue have now been addressed.

Henri Yandell made changes - 20/Oct/06 10:37 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Stephen Colebourne made changes - 21/Oct/06 11:26 AM
Link This issue relates to LANG-259 [ LANG-259 ]
Henri Yandell made changes - 06/Feb/07 11:47 PM
Status Resolved [ 5 ] Closed [ 6 ]