Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1241

Re: Dynamic enums

From markspace <-@.>
Newsgroups comp.lang.java.help
Subject Re: Dynamic enums
Date 2011-10-11 19:32 -0700
Organization A noiseless patient Spider
Message-ID <j72u8g$7tc$1@dont-email.me> (permalink)
References <4e94eeb1$0$16274$9a566e8b@news.aliant.net>

Show all headers | View raw


On 10/11/2011 6:34 PM, Linus Flustillbe wrote:
>  So my question is, is there something like a dynamic enun:  by this
> could I call a method on the xxx enum like
>
> xxx.addnew("F") that would make F a valid enum


Basically, no (as Eric said) unless you roll your own class and forgo 
literal enums (as Lew said).

Personally I'd do the latter.  You should not use an enum for a table 
value imo.  It's an "impedance mismatch" (to borrow a term for 
electrical engineering).  Use a class that is made read only after the 
constructor executes, or can only be accessed by a special package, or 
whatever your requirements dictate.  Rolling an enum-like class is not 
hard, just requires a bit of thought.


Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Dynamic enums Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-12 01:34 +0000
  Re: Dynamic enums Lew <lewbloch@gmail.com> - 2011-10-11 19:03 -0700
  Re: Dynamic enums Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-11 22:05 -0400
    Re: Dynamic enums Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-11 22:11 -0400
      Re: Dynamic enums Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-12 06:02 +0000
        Re: Dynamic enums markspace <-@.> - 2011-10-11 23:44 -0700
        Re: Dynamic enums Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-12 07:58 -0400
          Re: Dynamic enums markspace <-@.> - 2011-10-12 07:46 -0700
  Re: Dynamic enums markspace <-@.> - 2011-10-11 19:32 -0700
  Re: Dynamic enums Roedy Green <see_website@mindprod.com.invalid> - 2011-10-12 07:02 -0700

csiph-web