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:
Henri Yandell 2009-03-08 01:07:17 +00:00
parent b23d1430ee
commit f5203850b0
1 changed files with 14 additions and 0 deletions

View File

@ -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>