Google Guava -- Write better Java Procedure

           Write better, more efficient Java, and hava fun doing so! --《Getting Started with Google Guava》

什么是Google?

Guava,最初在2007年开始的“谷歌集合库”,为使用Java集合提供了工具,谷歌Guava项目已经演变成一个基本工具包开发人员Java。有一些特性在其中包含类处理字符串、集合、并发、I / O和反射。函数接口使我们使用Java有函数式编程的能力和大大简化我们的代码。Upplier接口使用创造性模式。但Guava更不仅仅我们都觉得应该在Java中抽象的样板的Java,或方便方法。写一个好的代码,使其更有弹性和简洁。所以我的建议是不公正的使用Guava,但看源代码和感受Guava内部是怎么样运行的。然后尝试运用同样的原则你已经学会了自己的代码。Finally, have fun!

什么情况下使用Guava

作为软件开发者,我们希望我们可以做到。我们本能地想编写自己的库来处理我们日常看到的东西。当然,我们认为我们编写的代码是防弹的,我们知道为什么我们写单位测试,他们都通过!我有一些坏消息要告诉您,我们都是不那么聪明尽管我们很想这样做。其实,这真的不是你有多聪明。它更多的是写作不仅是单元测试的代码,但也被一大群开发人员和他们的输入重量的代码。Guava被数百个应用程序应用,截至2012年7月,有惊人的286000独立的单元测试guava-tests包中。所以,当它归结到它,你最好使用库如Guava,比你自己的。除此之外,据Larry Wall(Perl的作者),软件工程师的最好的品质之一是懒惰,不是“我不想工作”,而是“重复的创建轮子”的方式工作。很好的开发人员将寻找一个好的开源的第三方库帮助自己解决问题而不是自己重复造轮子。

引入Guava

1、直接到MVN创建去下载http://mvnrepository.com/
2、如果你使用的是Maven来构建项目。将以下的脚本添加到你的POM.XML文件中

<dependency>
	<groupId>com.google.guava</groupId>
	<artifactId>guava</artifactId>
	<version>19.0</version>
</dependency>
3、如果你使用的是Gradle来构建项目。你可以把以上的脚本添加到你的build.gradle文件中

compile group: 'com.google.guava' name: 'guava' version: '19.0'

关于本文

本文主要是介绍Guava的使用方法。当然其中可能会涉及到Guava的源码解析。以下就是需要介绍Guava的内容。

注意在本文中除了使用了Guava这个库,还使用了hamcrest-core-1.3.jar这个库

1、Guava的基本库
Guava base -- Joiner
Guava base -- Splitter
Guava base -- Charset
Guava base -- Strings
Guava base -- CharMatcher
Guava base -- Preconditions
Guava base -- Objects
Guava base -- MoreObject
Guava base -- Enums
Guava base -- Ascii
Guava base -- CaseFormat
Guava base -- Utf8

2、Guava函数式编程
Guava functional -- Function
Guava functional -- Predicate
Guava functional -- Supplier
3、Guava集合
Guava collections -- FluentIterable
Guava collections -- Lists
Guava collections -- Sets
Guava collections -- Maps
Guava collections -- Multimaps
Guava collections -- BiMap
Guava collections -- Table
Guava collections -- Range
Guava collections -- Immutable Collections
Guava collections -- Ordering
4、Guava并发
Guava concurrency -- Monitor
Guava concurrency -- ListenableFuture
Guava concurrency -- FuntureCallback
Guava concurrency -- SettableFuture
Guava concurrency -- AsyncFunction
Guava concurrency -- FutureFallback
Guava concurrency -- Futures
Guava concurrency -- RateLimiter
5、Guava缓存
Guava cache -- Cache
Guava cache -- CacheBuilder
Guava cache -- CacheBuilderSpec
Guava cache -- CacheLoader
Guava cache -- CacheStats
Guava cache -- RemovalListener
6、Guava EventBus
Guava EventBus -- EventBus
Guava EventBus -- Subscribe
Guava EventBus -- Event Publishing
Guava EventBus -- Finer-grained
Guava EventBus -- Unsubscribing
Guava EventBus -- AsyncEventBus
Guava EventBus -- DeadEvents
Guava EventBus -- Dependency injection
7、Guava File
Guava File -- Copying a File
Guava File -- Moving/rename a File
Guava File -- Working with files as strings
Guava File -- Hashing a file
Guava File -- Writing to files
Guava File -- InputSupplier and OutputSupplier
Guava File -- ByteSource
Guava File -- ByteSink
Guava File -- Copying from a ByteSource class to a ByteSink class
Guava File -- ByteStreams and CharStreams
Guava File -- Closer
Guava File -- BaseEncoding
8、Guava Odds&Ends
Guava Odds&Ends -- Creating proper hash functions
Guava Odds&Ends -- BloomFilter
Guava Odds&Ends -- Optional
Guava Odds&Ends -- Throwables

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值