Android
  • Introduction
  • Android Studio
    • AS的项目结构
    • adb
    • aapt
    • dx
    • Gradle
    • Kotlin on android
  • Smaller
  • decompiler
  • MISC
  • 框架 framework
  • 设计模式
  • dex
  • reinforce加固
  • code
    • Java Tips
      • 负数 negative
      • The Java Tutorials
        • 原始数据类型 Primitive Data Types
      • 运算符
        • 一元运算符
        • 算术运算符
        • 移位运算符
        • 关系运算符
      • 逻辑运算符
        • 逻辑 非 ! 关系值表
        • 逻辑 与 && 关系值表
        • 逻辑 或 || 关系值表
        • 与 & And
        • 或 | Or
        • 非 ~ Nor
        • 异或 ^ Xor
        • 赋值运算符
        • tips
      • == equals
      • Try Catch finally
        • 有意思的东西
      • String、StringBuilder、StringBuffer区别
      • inner classes、nested static classes
    • runtime_memory
    • javaStackTrace
    • Guava
    • FFMPEG
    • GoogleSamples
    • Full Kotlin Reference
    • release屏蔽Log代码
    • Thread
  • ANR
  • 注解改进代码检查
Powered by GitBook
On this page
  • User Guide[用户指南]
  • Basic utilities[基本工具]
  • Collections[集合]
  • Graphs图表
  • Caches缓存
  • Functional idioms函数风格
  • Concurrency并发
  • Strings字符串工具
  • Primitives原生类型
  • Ranges范围区间
  • I/O
  • Hashing散列
  • EventBus事件总线
  • Math数学实用工具
  • Reflection反射
  • Tips小技巧

Was this helpful?

  1. code

Guava

PreviousjavaStackTraceNextFFMPEG

Last updated 5 years ago

Was this helpful?

Guava: Google Core Libraries for Java.

Docs: - -

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. Guava工程包含了若干被Google的Java项目广泛依赖的核心库:**集合 [collections]** 、**缓存 [caching]** 、**原生类型支持 [primitives support]** 、**并发库 [concurrency libraries]** 、**通用注解 [common annotations]** 、**字符串处理 [string processing]** 、**I/O** 等。 这些工具常被Google应用于产品服务中。

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. 让使用Java语言变得更舒适

  1. 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.

    使用和避免null:null是模棱两可的,会引起令人困惑的错误,有些时候它让人很不舒服。很多Guava工具类用快速失败拒绝null值,而不是盲目地接受

  2. Preconditions: Test preconditions for your methods more easily.

    前置条件: 让方法中的条件检查更简单

  3. Common object methods: Simplify implementing Object methods, like hashCode() and toString().

    常见Object方法: 简化Object方法实现,如hashCode()和toString()

  4. Ordering: Guava's powerful "fluent Comparator" class.

    排序: Guava强大的”流畅风格比较器”

  5. 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. 前置条件: 让方法中的条件检查更简单

  1. Immutable collections, for defensive programming, constant collections, and improved efficiency.

    不可变集合: 用不变的集合进行防御性编程和性能提升。

  2. 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.

    新集合类型: multisets, multimaps, tables, bidirectional maps等

  3. Powerful collection utilities, for common operations not provided in java.util.Collections.

    强大的集合工具类: 提供java.util.Collections中没有的集合工具

  4. Extension utilities: writing a Collection decorator? Implementing Iterator? We can make that easier.

    扩展工具类:让实现和扩展集合类变得更容易,比如创建Collection的装饰器,或实现迭代器

Graphs图表

a library for modeling graph-structured data, that is, entities and the relationships between them. Key features include:

  1. Graph

    a graph whose edges are anonymous entities with no identity or information of their own.

  2. ValueGraph: a graph whose edges have associated non-unique values.

  3. Network: a graph whose edges are unique objects.

  4. Support for graphs that are mutable and immutable, directed and undirected, and several other properties.

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. 强大而简单的抽象,让编写正确的并发代码更简单

  1. ListenableFuture Futures, with callbacks when they are finished. ListenableFuture:完成后触发回调的Future

  2. Service Things that start up and shut down, taking care of the difficult state logic for you. Service框架:可开启和关闭的服务,帮助你维护服务的状态逻辑

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. 可比较类型的区间API,包括连续和离散类型

I/O

Simplified I/O operations, especially on whole I/O streams and files, for Java 5 and 6. 简化I/O尤其是I/O流和文件的操作,针对Java5和6版本

Hashing散列

Tools for more sophisticated hashes than what's provided by Object.hashCode(), including Bloom filters. 提供比Object.hashCode()更复杂的散列实现,并提供布鲁姆过滤器的实现

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. Guava 的 Java 反射机制工具类

Tips小技巧

Getting your application working the way you want it to with Guava.

  1. Philosophy

    what Guava is and isn't, and our goals.

  2. Using Guava in your build, with build systems including Maven, Gradle, and more.

  3. Using ProGuard to avoid bundling parts of Guava you don't use with your JAR.

  4. Apache Commons equivalents, helping you translate code from using Apache Commons Collections.

  5. Compatibility, details between Guava versions.

  6. Idea Graveyard, feature requests that have been conclusively rejected.

  7. Friends, open-source projects we like and admire.

  8. HowToContribute, how to contribute to Guava.

NOTE: To discuss the contents of this wiki, please just use the guava-discuss mailing list.

Repository
guava
guava-testlib
Google Guava Wiki
Google Guava官方教程(中文版)