I would go with valueOfDisplayName(). I would actually add a
displayName() as well, just like we have name(). I am not a fan of
assuming that toString() == displayName()
-- Blake Sullivan
On 2/14/12 4:21 AM, Andy Schwartz wrote:
Thanks for the comments guys.
On Mon, Feb 13, 2012 at 11:51 PM, Blake Sullivan
<blake.sulli...@oracle.com> wrote:
Overloaded how?
The other question is that we want to be able to go from the
displayName->Enum
Actually, this is the only question. :-)
We've already got an "accessor" - the Accessibility enum overrides
toString() to return the display name/pretty name/alias that gets
passed in when the constant is created.
What I need is a way to map back from the toString() value to the
corresponding enum constant. For this, we should follow the pattern
set by Enum.valueOf(). So, we'll want something like:
Accessibility.valueOfTheStringThatGetsReturnedFromToStringNotTheEnumConstantName()
But shorter.
Maybe:
- valueOfDisplayName()? Or...
- valueOfAlias()?
Whatever name we come up with, I will:
- Update the name of the Accessibility enum constant constructor
argument to match.
- Add javadoc to toString() that clarifies that it returns the display
name/alias/whatever we call it.
Andy