(Java) Guava Study notes: Introduction to Google Guava Class library

Source: Internet
Author: User
Tags google guava eventbus

Guava is an extended project of Google's java1.6-based class library collection, including collections, caching, primitives support, concurrency libraries, common Annotati ONS, string processing, I/O, and so on. These high-quality APIs can make your Java code more elegant and concise, making your work easier and more enjoyable. Let's start the elegant Java programming learning journey!

  Project related information:

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

simple description of the source package:  
com.google.common.annotations: Common annotation type.  
Com.google.common.base: Basic tools class libraries and interfaces.  
Com.google.common.cache: Caching toolkit, a very easy-to-use and powerful in-JVM cache.  
Com.google.common.collect: A collection interface extension and implementation with generics, and a tool class, where you'll find a lot of fun collections.  
Com.google.common.eventbus: The event bus that publishes the subscription style.  
Com.google.common.hash: Hash toolkit.  
Com.google.common.math: The original arithmetic type and the arithmetic toolkit for the extra-large number.  
Com.google.common.net: Network toolkit.  
Com.google.common.primitives: Eight static toolkits of primitive types and unsigned types.  
Com.google.common.reflect: Reflection Toolkit.  
Com.google.common.util.concurrent: Multithreading toolkit.

  Class Library User manual:

  I. Basic TOOLS class: make using the Java language more enjoyable.

1. The use and avoidance of null:null language ambiguity can create puzzling errors, which he always makes people uncomfortable. Many guava tool classes reject or fail directly when they encounter NULL, rather than accepting them silently.
2. Prerequisites: It is easier to test your approach with preconditions.
3. Common Object methods: Simplified implementation of object common methods, such as Hashcode () and toString ().
4. Sort: Guava powerful "fluent Comparator" comparator, providing multi-keyword sorting.
5. Throwable class: Simplifies exception checking and error propagation.

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

1. Immutable Collections (Immutable collection): Defensive programming, non-modifiable collections, and increased efficiency.
2. New collection types (collection type): JDK collections does not have some collection types, mainly: Multisets,multimaps,tables, bidirectional maps, etc.
3. Powerful collection utilities (powerful Collection tool Class): Common operations Tool classes not included in Java.util.Collections
4. Extension Utilities (Extension tool Class): Add an adorner to the Collection object? Implement iterators? We can use these methods more easily.

  three. cache : Local cache, easy to operate cache objects, and support a variety of cache failure behavior patterns.

  Four. Functional Idioms (functional): Concise, guava implements the functional programming of Java, which can significantly simplify the code.

  five. Concurrency (concurrency): powerful, simple abstraction that makes it easier to implement simple and correct concurrency code.

1. Listenablefuture (Can monitor the future): Futures, callback for asynchronous completion.
2. Service: Controls the start and shutdown of events, and manages complex state logic for you.

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

  Seven. Primitives: extends operations that are not provided in the JDK to native types (such as int, char, and so on), including some types of unsigned variables.

  eight. Ranges: Guava A powerful API that provides range processing for comparable types, including continuous and discrete scenarios.

  Nine. I/O: simplifies I/O operations, especially for I/O streams and files, for Java 5 and 6.

  10. Hashing: provides a more complex hashing method than Object.hashcode (), providing Bloom filters.

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

  12. Math: optimized Math tool class, fully tested.

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

(Java) Guava Learning Note: Introduction to Google Guava Class library

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.