Free Sample
+ Collection

Getting Started with Google Guava

Starting
Bill Bejeck

Google Guava can transform the way you work with Java and this book shows you how. From beginner to expert, everyone can benefit from this smart guide that teaches faster, better coding.
$14.99
$24.99
RRP $14.99
RRP $24.99
eBook
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781783280155
Paperback142 pages

About This Book

  • Write more robust code that is easier to read and maintain
  • Learn how to use Preconditions to prevent and find errors faster
  • Shows how Guava Collections can make working with Java Collections a breeze

Who This Book Is For

There is no minimum level of experience required. There is something for everyone who works with Java, from the beginner to the expert programmer.

Table of Contents

Chapter 1: Getting Started
Introducing Google Guava
The case for using Guava
What is this book about?
Installing Guava
Using Guava with Maven or Gradle
Summary
Chapter 2: Basic Guava Utilities
Using the Joiner class
Using the Splitter class
Working with strings in Guava
Using the CharMatcher class
Using the Preconditions class
Object utilities
Summary
Chapter 3: Functional Programming with Guava
Using the Function interface
Using the Functions class
Using the Predicate interface
Using the Predicates class
Using the Supplier interface
Using the Suppliers class
Summary
Chapter 4: Working with Collections
The FluentIterable class
Lists
Sets
Maps
Multimaps
BiMap
Table
Range
Immutable collections
Ordering
Summary
Chapter 5: Concurrency
Synchronizing threads
Monitor
ListenableFuture
FutureCallback
SettableFuture
AsyncFunction
FutureFallback
Futures
RateLimiter
Summary
Chapter 6: Guava Cache
MapMaker
Guava caches
CacheBuilder
CacheBuilderSpec
CacheLoader
CacheStats
RemovalListener
Summary
Chapter 7: The EventBus Class
EventBus
Subscribe – An example
Event Publishing – An example
Finer-grained subscribing
Unsubscribing to events
AsyncEventBus
DeadEvents
Dependency injection
Summary
Chapter 8: Working with Files
Copying a file
Moving/renaming a File
Working with files as strings
Hashing a file
Writing to files
InputSupplier and OutputSupplier
ByteSource
ByteSink
Copying from a ByteSource class to a ByteSink class
ByteStreams and CharStreams
Closer
BaseEncoding
Summary
Chapter 9: Odds and Ends
Creating proper hash functions
BloomFilter
Optional
Throwables
Summary

What You Will Learn

  • Master String manipulation with ease including creating a HashMap from formatted text
  • Harness the power of functional programming with Functions and Predicates
  • Use the power of Guava’s Collections classes
  • Get to grips with better ways of writing and reading files with less boilerplate
  • Improve synchronization with the Monitor
  • Create and use a self-loading cache for better performance
  • Leverage the power of event-based programming with the EventBus
  • Never get another NullPointerException by using the Optional class

In Detail

Java continues to maintain its popularity and is still one of the main languages used in the software industry today. But there are things in Java that are difficult to do that can be made easier; that’s where Guava comes in. Guava provides developers with a way to write better code, with less effort.

Getting Started with Google Guava will show the reader how to start improving their code from the very first chapter. Packed with examples and loads of source code, this book will have an immediate impact on how you work with Java.

This book starts with using Guava to help with the common tasks that Java developers perform. Then you’ll work your way through more specialized situations and finally some great functionality Guava provides that can add a lot of power to your applications with little effort. You will learn about Guava’s famous Collections classes that add unique features, like the Bi-Map, to Java’s already great Collection classes. We’ll see how to add some functional programming aspects to our code. We will also learn about using a self-loading cache for improved performance in our applications, and how to use the EventBus to create software that takes advantage of event-based programming.

Authors

Read More