通用共享集合
我很惊讶 Apache Commons Collections 项目仍然没有抽出时间来制作他们的库泛型-意识到的。 我真的很喜欢这个库提供的功能,但缺乏对泛型的支持是一个很大的障碍。 有一个 Commons Collections 的 Lavalabs 分支,它确实支持泛型,它似乎声称向后兼容,但是当我尝试更新到此版本时,我的 Web 应用程序无法启动(在 JBoss 中)。
我的问题是:
- 是否有人已成功从 Commons Collections 更新到上述分支
- 如果 Commons Collections 有任何计划添加对泛型的支持
顺便说一句,我知道 Google 集合,但在 API 稳定之前不愿意使用它。
干杯, 大学教师
I'm astonished that the Apache Commons Collections project still hasn't got around to making their library generics-aware. I really like the features provided by this library, but the lack of support for generics is a big turn-off. There is a Lavalabs fork of Commons Collections which does support generics, which seems to claim backward compatibility, but when I tried updating to this version, my web application failed to start (in JBoss).
My questions are:
- Whether anyone has successfully updated from Commons Collections to the fork mentioned above
- If Commons Collections has any plans to add support for generics
BTW, I'm aware of Google collections, but am reluctant to use it until the API stabilises.
Cheers,
Don
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
请考虑 Google 收藏集。 来自他们的 Javalobby 采访:
Consider Google Collections. From their Javalobby interview:
有贡献。 查看 jira 的
还有一个 JDK5 分支。
我们确实希望添加泛型并将 Commons Collections 更新到 1.5(和 1.6)。 最大的问题是如何解决向后兼容性。 那里的人们有非常不同的看法。 对于某些 Commons 组件,较新的 JDK 几乎要求为新的 JDK 重写(恕我直言)。
在 ApacheCon 期间,我感受到了一些人想要推动这一举措的冲动。 这只是一项艰巨的任务。
请随意出现在[电子邮件受保护]
干杯,
托斯顿
There are contributions. Checkout the jira's
There is also a JDK5 branch.
We do would like to add generics and update Commons Collections to 1.5 (and 1.6). The biggest problem is how to address backwards compatibility. And people have very different opinions there. For some of the Commons components the newer JDK almost asks for a rewrite for the new JDKs IMHO.
During ApacheCon I felt the urge across several people to get this moving though. It's just a big task.
Feel free to show up on [email protected]
cheers,
Torsten
鉴于雅加达自己的内部 辩论是在 12 月 7 日,我想说 Apache 不会接受泛型,为 Java5 友好的东西留下了空间,比如Google 收藏集。
Given that the last word in Jakarta's own internal debate was in Dec 07, I would say that Apache will not embrace generics, leaving the field open for something Java5 friendly like Google Collections.
我说,硬着头皮切换到谷歌集合,至少对于新代码来说是这样。
我知道您担心稳定性,但是 google-collections 库对于 1.0 版本来说非常接近稳定 - 在开发列表中闲逛或观看他们报告的问题,他们已经对更改非常非常谨慎,尤其是破坏性的更改。 当前版本和(似乎即将到来的)1.0 最终版本之间的任何不兼容性都将非常小。
另外,如果您担心稳定性,请选择一个版本(例如当前版本,1.0 RC4),然后...就不要升级。 当然,您不会获得任何新功能,但是 commons-collections 已经有好几年没有以有意义的方式更新了,所以您的情况真的更糟吗? 至少你对泛型和(恕我直言)更好的 API 感兴趣。
I say, bite the bullet and switch to google-collections, at least for new code.
I know you're concerned about stability, but the google-collections library is VERY close to stable for 1.0 release -- hang out on the dev list or watch their reported issues, they are already very very cautious about changes, especially breaking ones. Any incompatibilities between the current release and the (seemingly imminent) 1.0 final are going to be extremely tiny.
Also, if you're worried about stability, pick a version (e.g. the current one, 1.0 RC4), and... just don't upgrade. Sure, you won't get any new features, but commons-collections hasn't been updated in a meaningful way in several years, so are you really any worse off? At least you're frozen on something with generics and (IMHO) a much better API.
一般的 BC 问题是包
org.apache.commons.collections
已重命名为org.apache.commons.collections15
。 我不知道这个变化的原因。 尝试将其重命名回来,重新编译库并再次运行您的应用程序。我在
commons-collections-3.2.1.jar
上使用 Clirr 工具发现了此问题(来自 Apache)和collections-generic-4.01.jar
(来自 Lavalabs)。The general BC problem is that package
org.apache.commons.collections
has been renamed toorg.apache.commons.collections15
. I don't know the reason of this change. Try to rename it back, recompile the library and run your application again.I have found this issue using Clirr tool on
commons-collections-3.2.1.jar
(from Apache) andcollections-generic-4.01.jar
(from Lavalabs).我无法想象你有什么理由不使用谷歌收藏。 使用该库非常简单。
对于我的工作,我同时使用 apache 集合和 google 集合。
你能详细解释一下为什么你不能使用谷歌收藏吗?
问候
I can't imagine what reason you can have to don't use google collections. It's quite simple to use that library.
For my work i use both, apache collections and google collections.
can you explain more about why you can't use google collections?
regards
这里有 Commons Collections 3.1 的通用端口可用,我们已经使用它好几年了。 做得很好,而且由于它严格基于现有的 Commons 源代码,因此它具有稳定的 API。
不过,它可以使用更新来符合 Commons Collections 3.2。
There's a genericised port of Commons Collections 3.1 available here, which we've been using for a few years now. Does the job nicely, and since it's based strictly on the existing Commons source, it has a stable API.
It could use updating to conform to Commons Collections 3.2, though.
阅读集合博客,它提供了对集合框架的完整理解。
http://tech.konnectingtheworld.com/2010/09/ a-note-on-java-collections/
如果您觉得您的问题没有得到解答,请与我联系。 我将尽力向您提供尽可能多的信息。
Have a read on the collection blog, it provide the completed understanding of the collection framework.
http://tech.konnectingtheworld.com/2010/09/a-note-on-java-collections/
If you feel that you query has not been answered, get in touch with me. I shall try to provide you the information as much as I can.