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


Groups > comp.lang.java.programmer > #26094

Re: limitations on using enum as generic parameter

From Ken Wesson <kwesson@gmail.com>
Subject Re: limitations on using enum as generic parameter
Newsgroups comp.lang.java.programmer
References <76e9be77-f846-4559-82ec-1d774a8a6a0b@q36g2000yqn.googlegroups.com> <4d518f96$1@news.x-privat.org> <iis5qe$6o3$1@news.eternal-september.org>
Message-ID <4d519c14$1@news.x-privat.org> (permalink)
Date 2011-02-08 20:40 +0100
Organization X-Privat.Org NNTP Server - http://www.x-privat.org

Show all headers | View raw


On Tue, 08 Feb 2011 20:33:37 +0100, Daniele Futtorovic wrote:

> On 08/02/2011 19:46, Ken Wesson allegedly wrote:
>> That's not going to work. It's a static method of a class that isn't
>> determined at this point in the code, so the compiler simply has no
>> clue what to call. Hence the error message.
>>
>> If you really need to do something like this, you'll need to use
>> reflection on a class object.
> 
> For the record: no. See my and ninja markspace's replies.

I meant the general case of wanting to invoke a static method on a type 
parameter, where the method depends on the run-time type (so, it's not a 
method of X where you have <E extends X>, but a method implemented 
differently for each choice of E).

In the special case of an enum there's getEnumConstants.

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


Thread

Re: limitations on using enum as generic parameter Daniele Futtorovic <da.futt.news@laposte.net.invalid> - 2011-02-08 20:33 +0100
  Re: limitations on using enum as generic parameter Lew <lew@lewscanon.com> - 2011-02-09 10:07 -0800
  Re: limitations on using enum as generic parameter Daniele Futtorovic <da.futt.news@laposte.net.invalid> - 2011-02-08 23:44 +0100
  Re: limitations on using enum as generic parameter Daniele Futtorovic <da.futt.news@laposte.net.invalid> - 2011-02-08 20:47 +0100
    Re: limitations on using enum as generic parameter Lew <lew@lewscanon.com> - 2011-02-08 12:31 -0800
  Re: limitations on using enum as generic parameter Ken Wesson <kwesson@gmail.com> - 2011-02-08 20:40 +0100

csiph-web