Guava is Google's core Java library that provides common utilities and extensions to the Java collections framework. It targets Java 5+ and benefits from generics. Some key features include validation checks, joining/splitting strings, hashcode/equals implementation assistance, file I/O utilities, and collection types like BiMap and Multimap that allow multiple values per key. Guava is well designed but not a complete replacement for Apache Commons and requires Java 5 or higher.
3. Guava Overview
Google’s core Java libraries for Java 5+
The Apache Software License, Version 2.0
Similar to Apache Commons
Extension of the Java Collections Framework
Google Collection
4. Guava vs Apache Commons
Generics
Guava targets Java 5 - Greatly benefits from the
Java 5 features: generics, enums, autoboxing ..
5. Guava vs Apache Commons
Consistency with Collections framework
Correctness – don’t need to test
Guava has only one code dependency -
javax.annotation
18. Guava Library & Examples
com.google.common.collect.Multimaps
allow multiple values to be stored for every key
19. Guava Library & Examples
com.google.common.collect.BiMap
one-to-one bidirectional relationship between key
and value of the Map
20. Guava Library & Examples
com.google.common.collect.Constraints
Similar to preconditions in a way that they can restri
ct what values are added to a collection
21. Guava Pros & Cons
Guava targets Java 5 - Greatly benefits from the
Java 5 features: generics
Guava is very well designed / documented
The code is useful patterns to make the API more
readable, secure, thread-safe..
Functional programming support
22. Guava Pros & Cons
It's not a sufficient replacement for Apache
Commons, in particular commons-codec
If you're in an environment requiring Java 1.3 or
1.4, you're out of luck.