[
https://issues.apache.org/jira/browse/WICKET-5350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13766717#comment-13766717
]
Betlista commented on WICKET-5350:
----------------------------------
In fact this is related problem. My problem with this API is, that I can't do
ListMultipleChoice<String> choice = new
ListMultipleChoice<String>("id");
choice.getChoices().add("abc"); // compilation problem
reporter of WICKET-5184 reported that
List<String> stringList = new ArrayList<String>();
IModel<List<? extends String>> listModel = Model.ofList(stringList);
listModel.getObject().add("abc"); // compilation problem
also fails with compilation error, which is ok from compiler point of view, but
really not intuitive from users point of view.
Model.of() should not convert List<C>/Set<C>/Collection<C> to ? extends C
If user uses List<? extends C> and calls Model.ofList(List<T>), he/she will get
instance of List<? extends C>, even if he/she has instance of List<C> list and
wants List<? extends C>, he/she can simply use casting Model.ofList((List<?
extends C>) list) and conversion from List<C> to IModel<List extends C> is done.
> Enahancement for AbstractChoice and WildcardListModel API
> ---------------------------------------------------------
>
> Key: WICKET-5350
> URL: https://issues.apache.org/jira/browse/WICKET-5350
> Project: Wicket
> Issue Type: Improvement
> Affects Versions: 7.0.0, 6.10.0
> Reporter: Betlista
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira