extend « enum « Java Data Type Q&A

1. Java extend enum    stackoverflow.com

Is something like this possible in Java. I want to take an existing enum and add more elements to it

enum A {a,b,c}

enum B extends A {d}

/*B is {a,b,c,d}*/

2. Is it possible to extend Java Enums?    stackoverflow.com

Here's what I am looking to accomplish, I have a class that has an enum of some values and I want to subclass that and add more values to the enum. ...

3. Configurable Values in Enum    stackoverflow.com

I often use this design in my code to maintain configurable values. Consider this code:

public enum Options {

    REGEX_STRING("Some Regex"),
    REGEX_PATTERN(Pattern.compile(REGEX_STRING.getString()), false),

4. Why in java enum is declared as Enum>    stackoverflow.com

Possible Duplicate:
java Enum definition
if language designers were to use simply Enum<E extends Enum> how would that affect the language? The only difference now would be ...

5. Extending a enum in Java    stackoverflow.com

I have a enum, lets call it A

public enum A

I have a function that takes a enum A

public void functionA(A enumA)

7. Simple extending enum question...    coderanch.com

9. Extending and reusing Enums    forums.oracle.com

Yes, lets say there is nothing we can do about the engineering. Ofcourse, if I had the option, the whole thing will be in a bin by now. Well I don't, and I have to live with that, so back to my enums issue. from the scriptlets, you can see how one if condition is a subset of the other. That ...

10. Why i cant extend enums    forums.oracle.com

Hey all, since java 1.5 i work with the new enums. Because they are very powerful, easy to handle and the code looks much better than uses thousands of "ifs". What i didnt understand until now, why i cant extend enum from other enums. This feature would be so nice, and i have a lot of ideas what i can do. ...

11. Extending enum again    forums.oracle.com

12. Extending enums    forums.oracle.com

A "workaround" that I have used to good effect is to use an interface for all your enums with common behaviour. That way you can easily write utility methods that can work with all those "types" of enums and have methods that can take the interface type etc.etc (basically all the Good Things of coding to an interface).

13. Extending enums during runtime    forums.oracle.com

14. extending typesafe enum    forums.oracle.com

Hi, Why do you want to restrict users from using the generated package? It sounds like a very weird design to create a "mirror" package. It doesn't feel right, and it seems like you are just doing something which doesn't add any value. Can you explain why you want this odd design? Kaj