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 tools:It makes it even 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 the 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, which allows you to conveniently operate on cached objects and supports various cache failure behavior modes.

  Iv. Functional idioms (function type ):Concise: Guava implements Java functional programming, which can significantly simplify the code.

  5. Concurrency (Concurrency ):Powerful and simple abstraction makes 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:Extends native type (such as int and char) operations not provided in JDK, including some types of unsigned variables.

  8. Ranges:Guava is a powerful API that provides Comparable range processing, including continuous and discrete situations.

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

  10. Hashing:Provides more complex hash methods than Object. hashCode () and Bloom filters.

  11. EventBus:Component communication based on the publish-subscribe mode does not need to be explicitly registered in the delegate object.

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

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

 

 

Related Article

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.