commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <j...@socialchange.net.au>
Subject Re: [lang] Enums
Date Sun, 21 Jul 2002 10:44:33 GMT
On Sat, Jul 20, 2002 at 10:07:44PM +0100, Stephen Colebourne wrote:
> First discussion point for adding to lang - Enumeration superclass.
> 
> Two enum classes have been suggested so far:
> http://cvs.apache.org/viewcvs/jakarta-avalon/src/java/org/apache/avalon/fram
> ework/
> Enum and ValuedEnum from Avalon
> 
> http://www.plotnix.com/enum/index.html
> from Dimitri Plotnikov

For those playing with Java Enums, I'd recommend reading this article:

"Beware of Java typesafe enumerations"
http://www.javaworld.com/javaworld/javatips/jw-javatip122.html

Dimitri's Enum does implement Serializable, possibly even correctly :)
Avalon's doesn't.

--Jeff

> Although Dimitris is more function rich, I think I prefer the Avalon code to
> start from. However, I would like to change the following in Enum:
> - Map handling code built in, rather than needing the subclass to be aware
> (note this may require a lightweight map implementation?)
> - asMap() method on Enum that returns the Map (unmodifiable)
> - asCollection() method on Enum that returns the values Collection
> (unmodifiable)
> - iterator() method on Enum that returns the value iterator of the Map
> (unmodifiable)
> - getEnum(String name) method that returns a typecast Enum object by name
> from the Map
> - the equals() method could use == for comparing Class objects?
> - javadoc recommendation for the subclass to have a typecast get by name
> method
> 
> to ValuedEnum I would change:
> - remove isXxx() methods, these are rather non-standard and encourage int
> comparisons (which the class is aiming to avoid!)
> - make the class Comparable based on the integer value (note that this means
> that Comparable equals will differ from equals()
> 
> Let the discussion commence...
> 
> Stephen
> 

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


Mime
View raw message