End of any doubt Googlers are our boss.
Among the thousands of libraries imported by Java programs on GitHub, Guava is the #2 (behind Log4J):
Although nearly 9,000 have starred it at time of writing, only around 1,000 are watching it.
Why This Page
The contribution of this particular page here is to present an understandable sequence to learn programming Java using library along with static code quality scanners (such as Qulice) and profilers (such as JProfiler)
I think this is what it takes to be a good and fast Java programmer today.
Might as well learn to do it right the first time than to pick up bad habits.
It’s kinda like learning to swim by diving into the deep end of a pool filled with Olympic swimmers.
This is probably why the Wikipedia page on Guava mentions that developers of the library don’t encourage outside contributions.
Get It on Your Laptop
On a Mac, create a group folder (google), then
git clone https://github.com/google/guava
Its license is permissive Apache.
Process its pom.xml file using Maven:
The starting point for the various components has been the repo’s own wiki:
Learn this as if an “immersive” experience like moving to Mexico to learn Spanish.
Or learning to cook in a 5-star restaurant. Well, this is like the names of knives.
basic utilities to reduce menial labors to implement common methods and behaviors, such as generics (introduced in JDK 1.5) extended with multisets, multimaps, bimaps, and immutable collections
an extension to the Java collections framework (JCF) formerly called the Google Collections Library,
other utilities which provide convenient and productive features such as functional programming, caching, range objects, and hashing
The structure of folders in the library:
Folders under the folders above:
There are similar ones in the Java Core library.
Each of these are specified at the top of programs using them, such as:
package com.google.common.annotations; import java.lang.annotation.Documented;
Some, such as Date, have not been removed.
Let’s look in library files within
Some have equivalent classes in the source.
|In src||In guava-test/benchmark|
Several of the files begin with this:
import com.google.caliper.BeforeExperiment; import com.google.caliper.Benchmark; import com.google.caliper.Param;
Google Caliper is used to benchmark some simple code.
Alternately, one can use Perfidix http://disy.github.io/perfidix/ which offers Eclipse Integration and can be used like JUnit. Another option is JUnitbenchmarks http://labs.carrotsearch.com/junit-benchmarks.html for Junit 4+ and build html charts to compare results.
New release every 3 months, with breaking changes. @Beta included in each release.
Docs on specific releases:
“Making Java Bearable with Guava 2015 Edition by Daniel Hinojosa of DZone” (March 11, 2015 at DevNexus):
- [10:19] Even though I use Scala now, I still use Multimap.
- [13:30] Multiset (Bag)
- [17:46] Immutability vs modifiability
- [21:02] Problem with Map only allows 5 items (no tuples in Java)
In this “Overview of Guava: Google Core Libraries for Java” (from 2012):
- [33:35] “the three mathematical properties that every comparator must have: reflexive, transitive, and anti-symetric. But I forgot what anti-symetric means”.
- ComparatorChain is more future-proof (if sort changes)
- [35:20] Hash maps: HashCode
- [41:30] BloomFilter provides common false positive values to avoid expensive queries
“Four reasons to use Guava” by Paul Gestwiki:
- [01:14] Lists named static methods instead of constructors
- [02:36] Maps wrapper around Collections
- [03:09] ImmutableList. are not just wrapper around core Java, for defensive
- [04:38] Preconditions
- [06:08] Range
“Google Guava - the Core Library You Always Wanted” by Mite Mitreski from Macendonia, Stockholm, Sweden:
- [03:18] It’s not clear what Null means (like Boolean)
- [09:14] JSR-305 Annotations for software defect detection
- [17:52] Wrapper overload (table) pack numbers within larger numbers
- [18:50] Utility classes end with s.
- [19:24] CharMatcher.WHITESPACE easier than RegEx.
- [21:15] Cache Builders have different ones for local (not external) for Eviction,
- [23:41] .weakKeys() can be garbage collected avoids memory leaks
- [25:12] .recordStats() for CacheStats.
- [26:00] Map != Cache
- [26:56] collect package for Immutable Collections
- etc. to 46.:05
If you speak German, from Eric Weiki:
From LevelUp Lunch: