Johan Compagner wrote:
yes i also thought about some time ago.But this is not really better... Now without you doing a cast in the code (so that you know what you are doing) you suddenly have a class cast exception at some point later on class MyComp extends Component { public MyComp() { IModel<Integer> model = getModel(); Integer myInt = model.getObject(); // KABOOM } because this thing gives you really a false kind of protection. This is really an abuse of generics if you ask me..
When I think about it, I have to agree. You can do ugly stuff like: IModel<Integer> x = getModel(); IModel<Double> y = getModel(); and it will compile just fine... :-( I'd rather have no generics than a dirty hack like this. Regards, Sebastiaan
johan On Wed, May 21, 2008 at 3:01 PM, Joni Freeman <[EMAIL PROTECTED]> wrote:On Wed, 2008-05-21 at 14:44 +0200, Sebastiaan van Erk wrote:Martijn Dashorst wrote:Generified component touches *ALL* code in Wicket, wether you care or not. IModel<T> itself is rather contained.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...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 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
smime.p7s
Description: S/MIME Cryptographic Signature