Shen Yiyang, Luo Lishu, He Yixin, Wu Zu
The introduction
The Guava project contains several core libraries that are widely relied upon by Google’s Java project, such as: Collections, Caching, Primitives support, Concurrency Libraries, Common Annotations , string processing, I/O, etc. All of these tools are being used every day by Google engineers in products and services.
Looking up Javadoc is not necessarily the most efficient way to learn about these libraries. Here, we hope to provide a more readable and explanatory account of some of Guava’s most popular and powerful features.
Translation format description
- The first time a class in Guava is referenced, it links to Guava’s API documentation. Such as: Optional < T >.
- When methods in Guava and the JDK are referenced, they are generally linked to the Guava or JDK API documentation, with the exception of some well-known JDK methods. Such as:Optional.of(T), a Map. The get (key).
- The translator’s additional notes to the document are shown in italics and end with”.:“To begin.
directory
1. [Basic Utilities]
Make it easier to use the Java language
1.1 Use and Avoid NULL: Null is ambiguous, can cause confusing errors, and can be uncomfortable in some cases. Many Guava utility classes reject null values with quick failures rather than blindly accepting them
1.2 Preconditions: Make condition checking in methods easier
1.3 Common Object methods: Simplified Object method implementation, such as hashCode() and toString()
1.4 Sorting: Guava’s powerful “Fluency Style comparator”
1.5 Throwables: Simplifies the propagation and checking of exceptions and errors
2. Collection/Collections
Guava’s extension to the JDK collection, which is the most mature and well-known part of Guava
2.1 Immutable Collections: Defensive programming and performance improvement with immutable collections.
2.2 New types of collections: Multisets, Multimaps, tables, Bidirectional Maps, etc
2.3 Powerful Collections utility classes: Provides Collections tools not available in java.util.Collections
2.4 Extending utility Classes: Make it easier to implement and extend Collection classes, such as creating decorators for collections, or implementing iterators
3. The cache[Caches]
Guava Cache: A local Cache implementation that supports a variety of Cache expiration strategies
4. Functional style[Functional idioms]
Guava’s functional support can significantly simplify code, but use it with caution
5. Concurrent [Concurrency]
Powerful and simple abstractions that make it easier to write proper concurrent code
5.1 ListenableFuture: Future that triggers the callback after completion
5.2 Service Framework: Abstracts services that can be turned on and off, helping you maintain Service state logic
6. String handling[Strings]
Very useful string tool, including split, join, fill, and so on
7. Primitive types[Primitives]
Extends operations on native types (such as int, char) not provided by the JDK to include unsigned forms of some types
8. interval[Ranges]
Interval API for comparable types, including continuous and discrete types
9. I/O
Simplify I/O operations, especially for I/O streams and files, for Java5 and 6 releases
10. hash[Hash]
Provides a more complex hash implementation than Object.hashcode () and provides an implementation of a Bloom filter
11. Event bus[EventBus]
Components communicate in publish-subscribe mode, but components do not need to be explicitly registered with other components
12. Mathematical operations[Math]
Optimized, well-tested math tool classes
13. reflection[Reflection]
Guava’s Java reflection mechanism utility class
This article links to the address: Google Guava official tutorial (Chinese version)
Add this article to my collection
Related posts:
- [Google Guava] 7- Native type
- [Google Guava] 12- Math
- [Google Guava] Sort: Guava’s powerful “Smooth style comparator”
- [Google Guava] 2.1- Immutable sets
- [Google Guava] 10- hash
- [Google Guava] 9-I/O
- [Google Guava] 1.2- Preconditions
- [Google Guava] 4- Functional programming
- [Google Guava] 6- String handling: split, join, fill
- [Google Guava] 1.1- Use and avoid NULL
- [Google Guava] 8-range
- [Google Guava] 2.4- Collection extension utility class
- [Google Guava] 1.3- Common Object methods
- ListenableFuture resolution for Google Guava package
- [Google Guava] 11- Event bus