So, I want the nicities of an enum, but I would like to extend the
enum list at runtime. is such a thing possible?
Example:
public enum Day {
MONDAY("Sucks");
private String comment;
Day(String comment) {this.comment = comment;}
}
// create a new Day enum Day.TUESDAY
// then
switch(day) {
case TUESDAY:
....
}
I am nearly certain it isn't possible, but I thought I would ask
anyways.
Christian Bongiorno
http://christian.bongiorno.org
Piotr Kobzda - 03 Aug 2007 23:19 GMT
> So, I want the nicities of an enum, but I would like to extend the
> enum list at runtime. is such a thing possible?
[quoted text clipped - 18 lines]
> I am nearly certain it isn't possible, but I thought I would ask
> anyways.
Assuming that's possible, how would you compile the above without a
TUESDAY present at compile time?
piotr
Daniel Pitts - 03 Aug 2007 23:38 GMT
> So, I want the nicities of an enum, but I would like to extend the
> enum list at runtime. is such a thing possible?
[quoted text clipped - 21 lines]
>
> Christian Bongiornohttp://christian.bongiorno.org
If you need to create new cases at runtime, you almost need to have a
scripting language to create/handle the new cases.
Roedy Green - 05 Aug 2007 15:54 GMT
On Fri, 03 Aug 2007 22:02:21 -0000, Sideswipe
<christian.bongiorno@gmail.com> wrote, quoted or indirectly quoted
someone who said :
>So, I want the nicities of an enum, but I would like to extend the
>enum list at runtime. is such a thing possible?
You probably won't like my answer, but you can compose Java source on
the fly and compile it, or compose class files on the fly.
See http://mindprod.com/jgloss/onthefly.html
Enum's are funny things. They don't let you add or remove
possibilities. They don't let you extended the methods.
There is Enumset though to play with various groups of enum constants.
see http://mindprod.com/jgloss/enumset.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com