On Mon, 16 Jul 2007 11:54:41 GMT, Roedy Green
<see_webs...@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :
You can't extend an enum to either add more enum constants or more
static methods or more instance methods on the enum constants, or more
instance datafields on each enum constant.
Why would I want to do such a thing? In this case I am working on the
Replicator which has two halves the applet that runs at the client
and the sender than runs on my machine. I wanted to keep the client
code as small as possible.
So wanted to have a core enum class, and extend it with extra methods
on each enum constant only used by the receiver and ditto for the
sender.
I did not want to repeat code since it would not stay in sync. So
what I did was a bit ugly but it works.
I passed an enum constant of the common enum class to the
corresponding enum constructor on the extending class. Then I wrote
wrapper methods to let the extending class present the common methods.
--
Roedy Green Canadian Mind Products
The Java Glossaryhttp://mindprod.com
Perhaps "enum" isn't the right construct for you. Perhaps an