Guava includes some core libraries used by Google in Java projects: collections, caching, primitives support, concurrency library, common annotations, string processing, and I/O. Google engineers use these tools every day during development.
However, it is not the most effective method to read Javadoc by learning how to make good use of these libraries. Here, we try to introduce the most common and powerful features of Guava in a readable, easy, and pleasant way.
Some parts of this wiki may not be completed yet.
- Basic utilities: makes Java easier to write.
- Use and avoid null:NullFuzzy meanings may cause inexplicable errors, which are annoying. Many Guava utilities refuse to use null blindly.
- Preconditions: it is easier to test the preconditions of a method.
- Common object method: SimplifiedThe implementation of Object methods, as shown in figureHashCode () andToString ().
- Sort: Guava powerful "fluentComparator"Class.
- Throw an exception: It simplifies the passing and verification of exceptions and errors.
- Collections: Guava's extension to JDK collections ecosystem. This is one of the most mature and commonly used parts of Guava.
- Immutable collection, which supports Defensive Programming and constant collection, can also improve efficiency.
- The new collection type supplements the scenarios where JDK collection is not perfect: multisets, multimaps, tables, bidirectional maps, etc.
- Powerful collection utilities, SupplementJava. util. Collections lacks common operations.
- Extension utilities: WriteCollectionDecorator? ImplementationIterator interface? We make it easier.
- Caches: The local cache is implemented correctly and supports a variety of expiration settings.
- Functional idioms: careful use of Guava's functional idiom can significantly simplify code.
- Concurrency: A Powerful and concise abstract structure makes writing concurrent code easier.
- ListenableFuture: Future mode. The callback function is called at the end.
- Service: you only need to specify opening and terminating to manage other complex state logic for you.
- Strings: some extremely useful string utilities: splitting, joining, padding, etc.
- Primitives: add the ones not in JDK, as shown in figureInt andChar and other basic types of operations. Including some typesUnsigned variation.
- Ranges: Guava's has powerful APIs for processingThe range of the Comparable type, including the continuous and discrete values.
- I/O: simplifies I/O operations, especially on I/O streams and files. Supports Java 5 and 6.
- Hashing: RatioObject. hashCode () more advanced hash tools, includingBloom filter.
- EventBus: Publish-subscribe-style component communication, no need to explicitly register between components.
- Math: the optimized and thoroughly tested math utilities that are not found in JDK.
- Reflection: Guava utilities that provide Java Reflection.
- TIPS: You can use Guava with ease.
- Concept: What is/is not, and our goal.
- Use Guava, such as Maven and Gradle, in your build.
- Use ProGuard to avoid adding redundant Guava parts to your JAR.
- Apache Commons equivalents helps you translate the Apache Commons Collections code.
- Compatibility: Update details of each Guava version.
- Propose a grave and feature proposal that has been thoroughly rejected.
- Links to other open-source projects that we like.
Note:To discuss the content of this wiki, please send an email to guava-discuss mailing list.