Documenting future of enums
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@751344 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b23d1430ee
commit
f5203850b0
|
@ -50,5 +50,19 @@
|
|||
}
|
||||
</pre>
|
||||
@since 2.1
|
||||
<h2>Migration to Java5</h2>
|
||||
<p>Java now provides Enums and the existing code can go away, with the following code changes. </p>
|
||||
|
||||
<p>Firstly rewrite your enum as a Java enum. See the
|
||||
<a href="http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html">Java tutorial</a> for more. </p>
|
||||
|
||||
<p>Then change the following: </p>
|
||||
|
||||
<pre>
|
||||
getEnum -> valueOf
|
||||
getEnumList -> new ArrayList( EnumSet.allOf(enumClass) ) // or just use an EnumSet
|
||||
iterator -> EnumSet.allOf(...).iterator()
|
||||
getEnumMap -> org.apache.commons.lang.EnumUtils.asMap(enumClass)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue