commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-819) EnumUtils.generateBitVector needs a "? extends"
Date Fri, 10 Jan 2014 13:38:08 GMT

    [ https://issues.apache.org/jira/browse/LANG-819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13867789#comment-13867789
] 

Thomas Neidhart commented on LANG-819:
--------------------------------------

The idea of using <? extends X> collections to prevent modification by compile-time
checks is new to me I have to admit. Although the add-type methods may not work, the resulting
collections are still modifiable, e.g. calling clear() or remove() will still work, thus I
am unsure if this is really sufficient and the right tool for this purpose. Afaik a better
way is to pass unmodifiable collections in such cases.

Anyway, your rant is a bit unfair, as we normally also allow this idiom as input argument
where possible, see for example the latest collections release.

btw. the guys at google do great stuff, so there surely must be a good reason why they do
not use the idiom all the time:

http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/collect/EnumMultiset.html#create%28java.lang.Iterable,%20java.lang.Class%29

Feel free to rant also on their mailinglist ...

> EnumUtils.generateBitVector needs a "? extends"
> -----------------------------------------------
>
>                 Key: LANG-819
>                 URL: https://issues.apache.org/jira/browse/LANG-819
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.0.1
>            Reporter: Shevek
>            Priority: Minor
>
>     public static <E extends Enum<E>> long generateBitVector(Class<E>
enumClass, Iterable<E> values) {
> Should be Iterable<? extends E>.
> This is because although no subclasses of E can exist, the "? extends" is a common idiom
for marking the collection as readonly, or not "owned" by the current object.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message