[ https://issues.apache.org/jira/browse/WICKET-5350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14076410#comment-14076410 ]
Carl-Eric Menzel commented on WICKET-5350: ------------------------------------------ Wildcards make collections read-only. You cannot add anything to a List<? extends Person>, because it might be a List<Employee>. You couldn't add a Manager to it then, nor could you add an Employee to a List<Manager>. It's especially annoying in the Model.of... case. You have a List<Person>, you use Model.ofList and you get back an IModel<List<? extends Person>> which is confusing and means you can't do this anymore: model.getObject().add(myPerson). It's read-only. So if you have a list of something, you can't just give it as a model to a choice component by calling Model.of. In my opinion wildcards should be avoided unless there is a very good reason to use them. > Enhancement for AbstractChoice and WildcardListModel API > -------------------------------------------------------- > > Key: WICKET-5350 > URL: https://issues.apache.org/jira/browse/WICKET-5350 > Project: Wicket > Issue Type: Improvement > Affects Versions: 6.10.0, 7.0.0-M1 > Reporter: Betlista > Assignee: Sven Meier > Priority: Minor > Labels: generics > > According to Efective Java book > (http://devender.files.wordpress.com/2008/05/effectivejava.pdf), item 28: > "No wildcard type for return value" > Especially "User should not have to think about wildcards to use your API". > so > public List<? extends E> getChoices() > should be changed to > public List<E> getChoices() > and for WildcardListModel > protected List<? extends T> createSerializableVersionOf(List<? extends T> > object) > should be changed to > protected List<T> createSerializableVersionOf(List<? extends T> object) > Probably there is a lot of such things in framework. -- This message was sent by Atlassian JIRA (v6.2#6252)