I'm constantly running into problems with this method: public static <C> IModel<List<? extends C>> ofList(final List<? extends C> list)
This says that ofList takes, as a parameter, a List of C or some subclass of C, and returns a List of C or of some subclass of C. The problem that I keep having is that the type of the input list and the type of the output list may not be the same. I think that in practice they are, but the compiler does not know that. If C = StringedInstrument then the parameter may be List<Violin> while the returned list may be List<Guitar>. So every time I call Model.listOf, the type parameter of my List becomes hazy, which has annoying downstream effects. If I load a List<StringedInstrument> from a database, then pass it to Model.ofList, I wind up with a List<? extends StringedInstrument>--the compiler has no idea what the generic type of the List is, only that whatever it is, it is compatible with StringedInstrument. I can still get StringedInstrument instances out of the List, but I can't pass it to any method (like a component constructor) that takes a List<StringedInstrument> or an IModel<List<StringedInstrument>> without ugly casting. Since Model.ofList must return a list that is compatible with the original list--it's a wrapper, not a transformer--can't it just take List<C> and return List<C>? Same goes for the other ofCollection-type methods. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Unfriendly-Model-ofList-etc-methods-can-anything-be-done-tp3302712p3302712.html Sent from the Users forum mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org