Guava Study Notes: Introduction to Google guava class library

Source: Internet
Author: User
Tags google guava eventbus
>

Guava is a Google Extension Project Based on java1.6 class library collection, including collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so on. these high-quality APIs can make your Java code more elegant, concise, and easier to work. Next we will start the elegant Java programming learning journey!

Project information:

Http://code.google.com/p/guava-libraries
Download: http://code.google.com/p/guava-libraries/downloads/list
Official documents: http://docs.guava-libraries.googlecode.com/git/javadoc

http://www.ostools.net/apidocs/apidoc?api=guava

A brief description of the source code package:
Com. Google. Common. Annotations: Common annotation type.
Com. Google. Common. Base: basic tool library and interface.
Com. Google. Common. cache: cache toolkit. It is a simple, easy-to-use and powerful JVM caching tool.
Com. Google. Common. Collect: extension and implementation of generic set interfaces, as well as tool classes. Here you will find many interesting collections.
Com. Google. Common. eventbus: publish a subscription-style event bus.
Com. Google. Common. Hash: Hash toolkit.
Com. Google. Common. IO: I/O toolkit.
Com. Google. Common. Math: a toolkit for primitive arithmetic types and super large numbers.
Com.google.common.net: Network toolkit.
Com. Google. Common. primitives: a static toolkit of eight primitive and unsigned types.
Com. Google. Common. reflect: Reflection toolkit.
Com. Google. Common. util. Concurrent: multithreading toolkit.

Class Library User Manual:

I. Basic tool class: it makes it more pleasant to use the Java language.

1. Use and avoid NULL: NULL has language ambiguity, which can lead to puzzling errors. It is always unpleasant. Many guava tool classes directly reject or make errors when encountering null, rather than silently accepting them.
2. Prerequisites: it is easier to test the prerequisites for your method.
3. Common Object Methods: This simplifies the implementation of common object methods, such as hashcode () and tostring ().
4. Sorting: the powerful "fluent comparator" comparator of guava provides multi-Keyword sorting.
5. throwable class: simplifies exception detection and error propagation.

Ii. Collection class: The collection class library is an extension of the JDK collection class by guava, which is the most complete and well-known part of the guava project.

1. Immutable collections (unchanged set): Defensive Programming, unchangeable set, and improved efficiency.
2. New Collection types (new collection type): Some Collection types not available in JDK collections, including: multisets, multimaps, tables, bidiremaps Al maps, etc.
3. Powerful collection utilities (powerful collection tool class): common operation tool classes not included in Java. util. Collections
4. Extension utilities (Extended tool class): Add a decorator to the Collection object? Implementation iterator? We can use these methods more easily.

Iii. cache: local cache allows you to conveniently operate on cached objects and supports various cache failure behavior modes.

Iv. Functional idioms: simple. Guava implements Java functional programming, which can significantly simplify the code.

5. Concurrency (concurrency): Powerful and simple abstraction, making it easier for us to implement simple and correct concurrency code.

1. listenablefuture (monitored future): futures, used for asynchronous callback.
2. Service: control the startup and shutdown of events to manage complex state logic for you.

6. Strings: a very useful string tool class: Provides splitting, joining, padding and other operations.

VII. primitives: extended operations not provided by JDK for native types (such as int and char), including some types of unsigned variables.

8. ranges: a powerful API of guava that provides comparable range processing, including continuous and discrete situations.

IX. I/O: Simplified I/O operations, especially for I/O streams and files. For Java 5 and 6.

10. hashing: provides a more complex hash method than object. hashcode () and Bloom Filters.

11. eventbus: component communication based on the publish-subscribe mode, but it does not need to be explicitly registered in the delegate object.

12. Math: optimized math tool class, which has been fully tested.

13. Reflection: Guava's Java reflection mechanism tool class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.