Sometimes I like to pass a String from some other tier (the UI for example)
and then use MyEnumeration.fromString(string) to construct this enumeration
which is then passed to the business tier for example.  The fromString (or
from whatever) method verifies the string is valid before construction.  I
like Strings most of the time because you don't need to remember what it
means because the value itself makes sense.

-----Original Message-----
From: Wouter Zoons [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 03, 2005 8:20 AM
To: Chad Brandon
Cc: [email protected]
Subject: RE: [Andromda-devel] enumerated entities

> [CB] If you don't use fromString() or fromInt() etc, how do you correctly
> construct enumerations from their actual underlying value (the String,
> integer, etc) and verify the value is valid according to the enum?
>

I use enums read-only .. I never needed to have the underlying value
exposed to me, I just want constants of the same custom type

the most frequent situation where I use them is when I need to pass in
some kind of simple value but don't want to use int or String because I
want both type-safety and a tight restriction on the possible values of
the argument (my enums are always final too)

perhaps you use them in combination with some kind of persistence
framework ? I never did.

-- Wouter





-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Andromda-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/andromda-devel

Reply via email to