Afaik, the type info isn't available at runtime for generic classes so it can't be done.
On Mon, 30 Oct 2006 18:24:27 +0100, Stephanos Piperoglou <[EMAIL PROTECTED]> wrote: > andyhot <[EMAIL PROTECTED]> wrote on 30/10/2006 16:30:08: > >> However, Daniel has recently added this in the BeanForm.sourceforge.net >> project. >> See >> http://beanform.sourceforge.net/beanform- >> core/xref/net/sf/beanform/util/EnumPropertySelectionModel.html >> >> or get the beanform jar and add it in your classpath > > Efxaristo :) > > Interestingly I had arrived at almost the exact same code by the time you > answered. This is the first time I've really used Java 1.5 in a production > environment and I was still struggling to find a way to shorten: > > public class EnumPropertySelectionModel<T extends Enum<T>> implements > IPropertySelectionModel { > public EnumPropertySelectionModel(Class<T> type, boolean > includeEmptyOption, Messages messages) > > ... so that the constructor doesn't need the class passed explicitly. > Surely the wonders of generics should allow such repetition to be made > redundant? 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! I just spent half a > day worrying about this inelegant solution so seeing that somebody else > seems to have used it did a lot to help me move on to actually writing > some code... but anybody have any ideas? > > Maybe this is a bit off-topic, so please tell me to fly off to > comp.lang.java if you must :) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]