[
https://issues.apache.org/jira/browse/COLLECTIONS-711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16999979#comment-16999979
]
Gilles Sadowski commented on COLLECTIONS-711:
---------------------------------------------
{quote}Make the return type Unmodified [...]
{quote}
This would reduce usability (in particular when the copy is made in order to
modify it while keeping the original intact).
Since the input collection type is unknown, a copy will be made in most cases;
hence consistency would dictate (IMO) that a copy is made too when the input is
a {{List}}. An application developer who wants to protect the return value from
modification can easily wrap it with a [single call to a JDK
method|https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#unmodifiableList(java.util.List)].
> Add Utility to Convert Collection to List
> -----------------------------------------
>
> Key: COLLECTIONS-711
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-711
> Project: Commons Collections
> Issue Type: Improvement
> Components: Collection, List
> Reporter: David Mollitor
> Priority: Major
>
> Please take a look at:
>
> [https://stackoverflow.com/questions/580160/how-to-convert-a-collection-to-list]
>
> Add a utility method to convert a {{Collection}} to a {{List}}, returning the
> argument if it is a {{List}} subclass itself. Make the return type
> Unmodified for consistency.since if the data comes in as a non-List class,
> then a copy is made, so modifying the returned collection would not affect
> the original source, whereas if a {{List}} is passed in, modification to the
> returned List would impact the original source.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)