Clone wiki

guava-jdk8 / Home

A library that facilitates the use of the Guava API under JDK 8

Getting Started

You can use the following Maven dependency:


Or download the files directly.

The Javadoc is at

The changelog is at


There are two ways to construct Stream collectors:

  1. Using direct constructors (e.g. GuavaCollectors.toImmutableSetMultimap()).
  2. Using Collector builders (e.g. GuavaCollectors.multimapFrom()).

The first approach supports common use-cases using a compact syntax. The second approach is more verbose but supports more advanced use-cases. For example:

public final class Testcase
    public static void main(String[] args)
        ImmutableSetMultimap<Integer, String> multimapWithoutSorting = Stream.of(10, 20, 40, 30, 15).
            collect(GuavaCollectors.toImmutableSetMultimap(i -> i / 10, i -> Integer.toString(i)));
        // Prints {1=[15, 10], 2=[20], 3=[30], 4=[40]}

        ImmutableSetMultimap<Integer, String> sortedMultimap = Stream.of(10, 20, 40, 30, 15).
                               map(i -> i / 10, i -> Integer.toString(i)).
                               sortKeys((a, b) -> b.compareTo(a)).
                               sortValues((a, b) -> b.compareTo(a)).
        // Prints {4=[40], 3=[30], 2=[20], 1=[15, 10]}

Versioning scheme

Given a version number MAJOR.MINOR.PATCH, we will increment the:

  • PATCH version when we make backwards-compatible changes.
  • MINOR version when we make binary-incompatible API changes, and
  • MAJOR version when we make source-incompatible API changes


  • Upgrading to a newer PATCH version will not require recompiling or changing user code.
  • Upgrading to a newer MINOR version will require recompiling user code.
  • Upgrading to a newer MAJOR version will require modifying and recompiling user code.

This guarantee does not apply to @Beta classes, methods or fields.


Licensed under the Apache License, Version 2.0: