您的位置:首页 > 产品设计 > UI/UE

Google Guava - GuavaExplained | User Guide(Guava用户指南)

2014-03-22 22:08 731 查看

GuavaExplained  Guava说明

Landing page for Guava explanations. 
explainedFeatured
Updated Jun 4, 2013 by lowas...@google.com

Guava用户指南

Guava项目包含若干Google的核心库, 包含如下项目: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O等等. 每个工具都在Google的生产环境中得到了应用,Google的工程师们每天都在使用它们.

但是通读JavaDoc并不是使用Java库的最有效方法. 这里, 我们尝试使用一种通俗易懂的方式着重介绍Guava中最常用和最强大的特性.

本wiki 正在编写中, 某些部分可能未完成.
Basic utilities: 让Java更好用.
Using and avoiding null
null
 是个很模糊的概念,
可能会导致令人混淆的错误, 而且有时的确让人不爽. 许多Guava工具类并不盲目接收null,一般会报错或快速失败.
Preconditions: 为你的方法提供更简单的前置条件.
Common object methods: 简化 
Object
 的方法实现,
像是
hashCode()
 和
toString()
.
Ordering: Guava的强大 "流式比较器" 类.
Throwables: 简化exceptions和errors的传播和检查.

Collections: Guava对JDK 集合系统的扩展. 这是Guava中最成熟和流行的部分.
Immutable collections, 用于防御式编程, 常量集合, 改进效率.
New collection types,  JDK collections没有涉及的场景: multisets, multimaps, tables, bidirectional maps等.
Powerful collection utilities, 用于提供 
java.util.Collections没有提供的公共操作
.
Extension utilities: 写一个 
Collection
 装饰器?
继承 
Iterator
? 都可以更简单.

Caches: 本地缓存, 支持多种有效期设定.
Functional idioms: 谨慎使用, Guava的functional idioms能够有效简化代码.
Concurrency: 强大而简单的抽象, 可以使编写正确并发代码的工作简化.
ListenableFuture: Futures, 结束的时候回调.
Service: 可以启动和结束的事物, 注意不同的状态逻辑.

Strings: 少量极度有用的工具: splitting, joining, padding等.
Primitives:  JDK 未提供的原生类型的操作, 包含某些类型的 unsigned变量.
Ranges: Guava的强大API可以轻松处理在
Comparable
 类型下的range,
不论连续或离散.
I/O: 简化 I/O 操作, 尤其是在 I/O 流和文件上的操作, 用于Java 5/ 6.
Hashing: 比 
Object.hashCode()更高级的哈希工具
,
包括 Bloom filters.
EventBus: 组件间发布-订阅模式的交流, 无需组件之间分派.
Math: 优化的, 完整测试的数学工具,提供了JDK没有涉及的功能.
Reflection: 使用Java反射能力的Guava工具.
Tips提示:精通Guava.
理念Philosophy: Guava是什么, 不是什么, 及其目标.
Using Guava in your build, 使用诸如Maven, Gradle等构建系统.
Using ProGuard避免在你的JAR中加入不必要的Guava部件.
Apache Commons equivalents, 从 Apache Commons Collections转向Guava.
Compatibility,  Guava版本变化细节.
Idea Graveyard, 被否决的特性.
Friends, 我们喜欢和尊敬的其他开源项目.

注意: 如果要评论此Wiki的内容, 请使用guava-discuss的邮件列表.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息