[prev in list] [next in list] [prev in thread] [next in thread]
List: tapestry-user
Subject: Re: Using java 1.5 enums as property selection models
From: Stephanos Piperoglou <stephanos.piperoglou () db ! com>
Date: 2006-10-31 11:26:41
Message-ID: OF95C35EDA.31076AA0-ON80257218.003D3D9A-80257218.003EDE55 () db ! com
[Download RAW message or body]
--=_alternative 003EDE5480257218_=
Content-Type: text/plain; charset="US-ASCII"
"Martin Strand" <martin.strand@entcap.se> wrote on 30/10/2006 17:33:32:
> On Mon, 30 Oct 2006 18:24:27 +0100, Stephanos Piperoglou <stephanos.
> piperoglou@db.com> wrote:
>
> > I was kind of expecting to be able to use a generic type (T
> > above) as an instance of java.lang.Class. Unsurprisingly, I can't.
> > Surprisingly, I can't find a way to work around it!
>
> Afaik, the type info isn't available at runtime for generic classes
> so it can't be done.
You're absolutely right; I was forgetting that generics in 1.5 are nothing
but glorified syntactic sugar; the compiler does the type checking and
then throws it all away. You need the class in the constructor for runtime
availability.
On the other hand, I'm still miffed that I have to use
java.lang.Class.getEnumConstants() (which I had to dig through the API to
find, and seems a bit inelegant even though the generic definition for the
class guarantees type safety) when all the tutorials mention the
<EnumType>.values() static method, which is defined for every subtype of
java.lang.Enum but not Enum itself! Of course it's because you can't have
abstract static methods in Java anyway... it just looks a bit ugly
Still, why am I complaining? It's a hell of a lot better than public
static final int CITY_NYC = 1... :)
Thanks for the timely response to the initial query and humoring my aside
guys!
---
This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
--=_alternative 003EDE5480257218_=--
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic