Joni Freeman wrote:
On Wed, 2008-05-21 at 14:44 +0200, Sebastiaan van Erk wrote:Martijn Dashorst wrote:Yes, but in my opinion rather useless as well. Plus you get heaps of @SuppressWarnings all over the place. Then just get rid of generics completely...Generified component touches *ALL* code in Wicket, wether you care or not. IModel<T> itself is rather contained.In which case would you need @SuppressWarnings? Consider for instance:interface IModel<T> { } class Component {private IModel<?> model; public <T> IModel<T> getModel() { return (IModel<T>) model; } }class MyComp extends Component {public MyComp() { IModel<Integer> model = getModel(); } } This compiles and the only warning is within wicket code. There's an unsafe cast to IModel<T>. Of course this would mean that getModel and getModelObject could throw classcastexception. It's a tradeoff: simple and more conservative usage of generics vs. fully type safe but complex and verbose usage of generics. Joni
That's pretty ok I guess, hadn't though of that. Better than returning a raw IModel. :-)
Does this always work nicely though, because you need to do a capture which means that the compiler must be able to infer the type... I've had problems before in these kind of situations that for me it seems obvious, but the compiler gives me an error and says it doesn't know what the type should be...
Regards, Sebastiaan
smime.p7s
Description: S/MIME Cryptographic Signature