Guava介绍

https://code.google.com/p/guava-libraries/wiki/GuavaExplained?tm=6

User Guide

用户指南


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

Guava项目包括几个Google的java项目都依赖的核心库,这些库包括:collections, caching, primitives support,concurrency libraries, common annotations, string processing, I/O等等。在我们的生产服务中,每天都在使用这些工具。


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

关于怎样使用这些库,查阅Javadoc不总是一个有效的学习方式。这里,我们试图以可读、舒适的方式向大家讲解Guava几个流行且强大的功能。


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

这个wiki是程序生成的,并且部分可能仍在构建中。

  • Basic utilities: Make using the Java language more pleasant.
  • 基础工具:使java编程变得更舒适。
    • 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时,会拒绝或者马上报错,而不是盲目的接受。
    • Preconditions: Test preconditions for your methods more easily.
    • 预置条件:使方法的条件检查更简单。
    • Common object methods: Simplify implementing Object methods, like hashCode() and toString().
    • 常用Object方法:使实现Object方法变得简单,如 hashCode()和 toString()。
    • Ordering: Guava's powerful "fluent Comparator" class.
    • 排序:Guava强大的“流式比较器”类。
    • Throwables: Simplify propagating and examining exceptions and errors.
    • Throwables使传播、检查异常和错误变得简单。
  • Collections: Guava's extensions to the JDK collections ecosystem. These are some of the most mature and popular parts of Guava.
  • 集合:Guava扩展了JDK集合体系。它们是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.
    • 新集合类型:提供了一些JDK没有的集合类:multisets, multimaps, tables, bidirectional maps等等。
    • Powerful collection utilities, for common operations not provided in java.util.Collections.
    • 强大的集合工具类:提供java.util.Collections没有的常用操作。
    • Extension utilities: writing a Collection decorator? Implementing Iterator? We can make that easier.
    • 扩展工具类:写一个集合装饰器?实现Iterator?我们能使它变得简单。
  • 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.
  • 函数式风格: Guava的函数式风格能大大简化代码,但请谨慎的使用。
  • Concurrency: Powerful, simple abstractions to make it easier to write correct concurrent code.
  • 并发:强大、简单的抽象使编写正确的并发代码变得简单。
    • ListenableFuture: Futures, with callbacks when they are finished.
    • ListenableFuture: 有回调方法的Future。
    • 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.
  • Strings:一些非常有用的String工具类,包括:分割,连接,填充等等。
  • Primitives: operations on primitive types, like int and char, not provided by the JDK, including unsigned variants for some types.
  • 原生类型:提供一些JDK没有的对原生类型的操作,例如int和char,还提供某些类型的无符号变量。
  • Ranges: Guava's powerful API for dealing with ranges on Comparable types, both continuous and discrete.
  • Ranges:Guava为可比较类型提供强大的API,包括连续和非连续的区间。
  • I/O: Simplified I/O operations, especially on whole I/O streams and files, for Java 5 and 6.
  • I/O:使Java5和6的I/O操作变得简单,特别是流和文件操作。
  • Hashing: Tools for more sophisticated hashes than what's provided by Object.hashCode(), including Bloom filters.
  • Hashing:提供比Object.hashCode()更复杂的Hash工具,以及布隆过滤器的实现。
  • EventBus: Publish-subscribe-style communication between components without requiring the components to explicitly register with one another.
  • EventBus:提供发布-订阅类型的组件通信,不需要组件明确的注册到另一个。
  • Math: Optimized, thoroughly tested math utilities not provided by the JDK.
  • Math:经过优化、彻底测试的数学工具。
  • Reflection: Guava utilities for Java's reflective capabilities.
  • 反射:Java反射工具类。
  • Tips: Getting your application working the way you want it to with Guava.
  • 提示:在你的应用中使用你想用的方式,应用Guava。
    • Philosophy: what Guava is and isn't, and our goals.
    • 理念:Guava是什么不是什么,以及我们的目标。
    • Using Guava in your build, with build systems including Maven, Gradle, and more.
    • 用Guava时的打包:使用打包工具,包括Maven,Gradle等等。
    • Using ProGuard to avoid bundling parts of Guava you don't use with your JAR.
    • 使用ProGuard避免在你的JAR中,打包你未使用的Guava部分。
    • Apache Commons equivalents, helping you translate code from using Apache Commons Collections.
    • Apache Commons 等值的,帮助你从Apache Comons集合转换代码到Guava。
    • Compatibility, details between Guava versions.
    • 兼容性,Guava版本之间的细节。
    • Idea Graveyard, feature requests that have been conclusively rejected.
    • 想法墓地,已经被拒绝的功能。
    • Friends, open-source projects we like and admire.
    • Friends,我们喜欢欣赏的开源项目。
    • HowToContribute, how to contribute to Guava.
    • 怎么贡献,怎么对Guava做贡献。

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

注意:请使用guava邮件讨论组,讨论这个wiki中的内容。

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Guava 是一个 Google 的基于java1.6的类库集合的扩展项目,包括 collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, 等等. 这些高质量的 API 可以使你的JAVa代码更加优雅,更加简洁,让你工作更加轻松愉悦。下面我们就开启优雅Java编程学习之旅!   项目相关信息:   官方首页:http://code.google.com/p/guava-libraries   官方下载:http://code.google.com/p/guava-libraries/downloads/list   官方文档:http://docs.guava-libraries.googlecode.com/git/javadoc http://www.ostools.net/apidocs/apidoc?api=guava   源码包的简单说明:   com.google.common.annotations:普通注解类型。   com.google.common.base:基本工具类库和接口。   com.google.common.cache:缓存工具包,非常简单易用且功能强大的JVM内缓存。   com.google.common.collect:带泛型的集合接口扩展和实现,以及工具类,这里你会发现很多好玩的集合。   com.google.common.eventbus:发布订阅风格的事件总线。   com.google.common.hash: 哈希工具包。   com.google.common.io:I/O工具包。   com.google.common.math:原始算术类型和超大数的运算工具包。   com.google.common.net:网络工具包。   com.google.common.primitives:八种原始类型和无符号类型的静态工具包。   com.google.common.reflect:反射工具包。   com.google.common.util.concurrent:多线程工具包。   类库使用手册:   一. 基本工具类:让使用Java语言更令人愉悦。   1. 使用和避免 null:null 有语言歧义, 会产生令人费解的错误, 反正他总是让人不爽。很多 Guava 的工具类在遇到 null 时会直接拒绝或出错,而不是默默地接受他们。   2. 前提条件:更容易的对你的方法进行前提条件的测试。   3. 常见的对象方法: 简化了Object常用方法的实现, 如 hashCode() 和 toString()。   4. 排序: Guava 强大的 "fluent Comparator"比较器, 提供多关键字排序。   5. Throwable类: 简化了异常检查和错误传播。   二. 集合类:集合类库是 Guava 对 JDK 集合类的扩展, 这是 Guava 项目最完善和为人所知的部分。   1. Immutable collections(不变的集合): 防御性编程, 不可修改的集合,并且提高了效率。   2. New collection types(新集合类型):JDK collections 没有的一些集合类型,主要有:multisets,multimaps,tables, bidirectional maps等等   3. Powerful collection utilities(强大的集合工具类): java.util.Collections 中未包含的常用操作工具类   4. Extension utilities(扩展工具类): 给 Collection 对象添加一个装饰器? 实现迭代器? 我们可以更容易使用这些方法。   三. 缓存: 本地缓存,可以很方便的操作缓存对象,并且支持各种缓存失效行为模式。   四. Functional idioms(函数式): 简洁, Guava实现了Java的函数式编程,可以显著简化代码。   五. Concurrency(并发):强大,简单的抽象,让我们更容易实现简单正确的并发性代码。   1. ListenableFuture(可监听的Future): Futures,用于异步完成的回调。   2. Service: 控制事件的启动和关闭,为你管理复杂的状态逻辑。   六. Strings: 一个非常非常有用的字符串工具类: 提供 splitting,joining, padding
是什么?它的特点和用途是什么? 回答: Guava Cache 是一个全内存的本地缓存实现,它是 Guava 中的一个模块,提供了线程安全的实现机制。它被广泛应用于 Java 项目中。 Guava Cache 的特点包括简单易用和性能好。它可以用来缓存计算结果、提高系统性能、减少对外部资源的依赖性等。 Guava Cache 提供了多种移除缓存的方式,包括单个移除、批量移除和移除全部。该缓存模块是 Guava 中的一个重要组成部分,而 Guava 是谷歌开源的 Java 工具类库,被许多 Java 项目所依赖。除了缓存功能,Guava 还提供了其他功能,如集合、并发库、通用注解等。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Guava Cache本地缓存介绍及使用](https://blog.csdn.net/unbelievevc/article/details/128365002)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Guava cache介绍](https://blog.csdn.net/elricboa/article/details/78734896)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值