Guava
Last updated
Was this helpful?
Last updated
Was this helpful?
Guava: Google Core Libraries for Java.
Docs: - -
The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. Each of these tools really do get used every day by Googlers, in production services. Guava工程包含了若干被Google的Java项目广泛依赖的核心库:**集合 [collections]** 、**缓存 [caching]** 、**原生类型支持 [primitives support]** 、**并发库 [concurrency libraries]** 、**通用注解 [common annotations]** 、**字符串处理 [string processing]** 、**I/O** 等。 这些工具常被Google应用于产品服务中。
But trawling through Javadoc isn't always the most effective way to learn how to make best use of a library. Here, we try to provide readable and pleasant explanations of some of the most popular and most powerful features of Guava.
This wiki is a work in progress, and parts of it may still be under construction.
Make using the Java language more pleasant. 让使用Java语言变得更舒适
Using and avoiding null: null can be ambiguous, can cause confusing errors, and is sometimes just plain unpleasant. Many Guava utilities reject and fail fast on nulls, rather than accepting them blindly.
使用和避免null:null是模棱两可的,会引起令人困惑的错误,有些时候它让人很不舒服。很多Guava工具类用快速失败拒绝null值,而不是盲目地接受
Preconditions: Test preconditions for your methods more easily.
前置条件: 让方法中的条件检查更简单
Common object methods: Simplify implementing Object methods, like hashCode() and toString().
常见Object方法: 简化Object方法实现,如hashCode()和toString()
Ordering: Guava's powerful "fluent Comparator" class.
排序: Guava强大的”流畅风格比较器”
Throwables: Simplify propagating and examining exceptions and errors.
简化了异常和错误的传播与检查
Guava's extensions to the JDK collections ecosystem. These are some of the most mature and popular parts of Guava. 前置条件: 让方法中的条件检查更简单
Immutable collections, for defensive programming, constant collections, and improved efficiency.
不可变集合: 用不变的集合进行防御性编程和性能提升。
New collection types, for use cases that the JDK collections don't address as well as they could: multisets, multimaps, tables, bidirectional maps, and more.
新集合类型: multisets, multimaps, tables, bidirectional maps等
Powerful collection utilities, for common operations not provided in java.util.Collections.
强大的集合工具类: 提供java.util.Collections中没有的集合工具
Extension utilities: writing a Collection decorator? Implementing Iterator? We can make that easier.
扩展工具类:让实现和扩展集合类变得更容易,比如创建Collection的装饰器,或实现迭代器
a library for modeling graph-structured data, that is, entities and the relationships between them. Key features include:
Graph
a graph whose edges are anonymous entities with no identity or information of their own.
ValueGraph: a graph whose edges have associated non-unique values.
Network: a graph whose edges are unique objects.
Support for graphs that are mutable and immutable, directed and undirected, and several other properties.
Local caching, done right, and supporting a wide variety of expiration behaviors. 本地缓存实现,支持多种缓存过期策略
Used sparingly, Guava's functional idioms can significantly simplify code. 函数式支持可以显著简化代码,但请谨慎使用它
Powerful, simple abstractions to make it easier to write correct concurrent code. 强大而简单的抽象,让编写正确的并发代码更简单
ListenableFuture Futures, with callbacks when they are finished. ListenableFuture:完成后触发回调的Future
Service Things that start up and shut down, taking care of the difficult state logic for you. Service框架:可开启和关闭的服务,帮助你维护服务的状态逻辑
A few extremely useful string utilities: splitting, joining, padding, and more. 非常有用的字符串工具,包括分割、连接、填充等操作
operations on primitive types, like int and char, not provided by the JDK, including unsigned variants for some types. 非常有用的字符串工具,包括分割、连接、填充等操作
Guava's powerful API for dealing with ranges on Comparable types, both continuous and discrete. 可比较类型的区间API,包括连续和离散类型
Simplified I/O operations, especially on whole I/O streams and files, for Java 5 and 6. 简化I/O尤其是I/O流和文件的操作,针对Java5和6版本
Tools for more sophisticated hashes than what's provided by Object.hashCode(), including Bloom filters. 提供比Object.hashCode()更复杂的散列实现,并提供布鲁姆过滤器的实现
Publish-subscribe-style communication between components without requiring the components to explicitly register with one another. 发布-订阅模式的组件通信,但组件不需要显式地注册到其他组件中
Optimized, thoroughly tested math utilities not provided by the JDK. 优化的、充分测试的数学工具类
Guava utilities for Java's reflective capabilities. Guava 的 Java 反射机制工具类
Getting your application working the way you want it to with Guava.
Philosophy
what Guava is and isn't, and our goals.
Using Guava in your build, with build systems including Maven, Gradle, and more.
Using ProGuard to avoid bundling parts of Guava you don't use with your JAR.
Apache Commons equivalents, helping you translate code from using Apache Commons Collections.
Compatibility, details between Guava versions.
Idea Graveyard, feature requests that have been conclusively rejected.
Friends, open-source projects we like and admire.
HowToContribute, how to contribute to Guava.
NOTE: To discuss the contents of this wiki, please just use the guava-discuss mailing list.