Java ——guava-libraries

来源:互联网 发布:三菱m70cnc传输软件 编辑:程序博客网 时间:2024/05/21 15:24

Google前日开源了其内部Java项目所用的Java库,并取名为Guava库(guava是番石榴的意思)。Guava库旨在提供核心JDK 1.6 API所没有的常用功能。Guava包括三个包:

◆com.google.common.primitives(原始值)

◆com.google.common.io(输入输出)

◆com.google.common.util.concurrent(并发)

以后还会发布更多的库。除了JDK 1.6,Guava库还可以在Android和Google App Engine等其他Java平台上使用。


The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth.

The latest release is 14.0.1, released March 15, 2013.

Start using Guava

You can download a JAR at:

  • guava-14.0.1.jar
  • guava-gwt-14.0.1.jar (for GWT users)

Guava is also available in Maven Central under the following identifiers:

  • com.google.guava:guava
  • com.google.guava:guava-gwt (for GWT users)

Learn more about how to UseGuavaInYourBuild.

Please see the 14.0.1 release notes for more details about this release.

Learn about Guava

  • Our users' guide, GuavaExplained
  • Browse API docs for the most recent release
  • Browse API diffs for the most recent release
  • Presentation slides focusing on base, primitives, and io
  • Presentation slides focusing on cache
  • Presentation slides focusing on util.concurrent
  • A nice collection of other helpful links

How to communicate with us (and each other)

To stay informed and get "tip of the week"-style posts, follow +Google Guava on Google+.

To just stay informed, period, about important news that every Guava user needs to know, subscribe to guava-announce. It is very low-traffic.

To report a defect or request a feature, click the Issues tab above and enter a new issue.

To get help on a specific question or problem, post a question to Stack Overflow with the tag "guava". We monitor these questions using this RSS feed.)

Keep an eye on project updates using any of these Project Feeds. (The "Updates" feed is an aggregation of all the others.) You can view our code changes as they happen, and comment on them using the code-review tool.

We have a read-only mailing list consisting of email notifications of issue tracker activity, which can be easier to follow in a threaded manner than the project feed.

For general discussion that doesn't fit neatly into any of these categories, join our discussion group guava-discuss.

Important Warnings

Guava contains a strictly compatible superset of the old, deprecated Google Collections Library. You should not use that library anymore.

APIs marked with the @Beta annotation at the class or method level are subject to change. They can be modified in any way, or even removed, in any major release. If your code is a library itself (i.e. it is used on the CLASSPATH of users outside your own control), you should not use beta APIs, unless you repackage them (e.g. using ProGuard). Here is a current list of all the beta APIs.

Serialized forms of ALL objects are subject to change. Do not persist these and assume they can be read by a future version of the library.

Deprecated non-beta APIs will be removed eighteen months after the release in which they are first deprecated. You must fix your usages before this time. If you don't, any manner of breakage might result (you are not guaranteed a compilation error).



User Guide

The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. Each of these tools really do get used every day by Googlers, in production services.

But trawling through Javadoc isn't always the most effective way to learn how to make best use of a library. Here, we try to provide readable and pleasant explanations of some of the most popular and most powerful features of Guava.

This wiki is a work in progress, and parts of it may still be under construction.

  • Basic utilities: Make using the Java language more pleasant.
    • Using and avoiding null: null can be ambiguous, can cause confusing errors, and is sometimes just plain unpleasant. Many Guava utilities reject and fail fast on nulls, rather than accepting them blindly.
    • Preconditions: Test preconditions for your methods more easily.
    • Common object methods: Simplify implementing Object methods, like hashCode() and toString().
    • Ordering: Guava's powerful "fluent Comparator" class.
    • Throwables: Simplify propagating and examining exceptions and errors.
  • Collections: Guava's extensions to the JDK collections ecosystem. These are some of the most mature and popular parts of Guava.
    • Immutable collections, for defensive programming, constant collections, and improved efficiency.
    • New collection types, for use cases that the JDK collections don't address as well as they could: multisets, multimaps, tables, bidirectional maps, and more.
    • Powerful collection utilities, for common operations not provided in java.util.Collections.
    • Extension utilities: writing a Collection decorator? Implementing Iterator? We can make that easier.
  • Caches: Local caching, done right, and supporting a wide variety of expiration behaviors.
  • Functional idioms: Used sparingly, Guava's functional idioms can significantly simplify code.
  • Concurrency: Powerful, simple abstractions to make it easier to write correct concurrent code.
    • ListenableFuture: Futures, with callbacks when they are finished.
    • Service: Things that start up and shut down, taking care of the difficult state logic for you.
  • Strings: A few extremely useful string utilities: splitting, joining, padding, and more.
  • Primitives: operations on primitive types, like int and char, not provided by the JDK, including unsigned variants for some types.
  • Ranges: Guava's powerful API for dealing with ranges on Comparable types, both continuous and discrete.
  • I/O: Simplified I/O operations, especially on whole I/O streams and files, for Java 5 and 6.
  • Hashing: Tools for more sophisticated hashes than what's provided by Object.hashCode(), including Bloom filters.
  • EventBus: Publish-subscribe-style communication between components without requiring the components to explicitly register with one another.
  • Math: Optimized, thoroughly tested math utilities not provided by the JDK.
  • Reflection: Guava utilities for Java's reflective capabilities.
  • Tips: Getting your application working the way you want it to with Guava.
    • Philosophy: what Guava is and isn't, and our goals.
    • Using Guava in your build, with build systems including Maven, Gradle, and more.
    • Using ProGuard to avoid bundling parts of Guava you don't use with your JAR.
    • Apache Commons equivalents, helping you translate code from using Apache Commons Collections.
    • Compatibility, details between Guava versions.
    • Idea Graveyard, feature requests that have been conclusively rejected.
    • Friends, open-source projects we like and admire.

     转载地址:http://1985wanggang.blog.163.com/blog/static/7763833201342353997/