Maps and List are the bread and butter of any Java program, but sometimes you need to creating a map that associates one key to multiple values and end up creating a Map> or similar. If you’ve ever needed that sort of collection, Guava has you covered with its Multimap. Guava’s Multimap is designed to represent a map where for one key there is a collection of values. There are two main variants (subinterfaces) of Multimaps: ListMultimap, which acts as if the collection is a List (meaning ...| andreabergia.com
Guava is one of the most well-known Java libraries. It includes various interesting things, such as preconditions, caches, bloom filters and various collections. Today, we’re going to discuss the immutable collections found in Guava. Motivation Immutable objects are generally really good things to have in a program: being immutable means that they are automatically thread-safe (since no one can modify them, you don’t need locks!). Furthermore, since they cannot be change, they can be used...| andreabergia.com
Optional is a new class introduced in Java 8. However, a very similar class has been available in Guava for quite some time. Optional is a generic class which should be used to represent the concept that a value might be missing. Very often methods that might return a valid object only under some conditions end up returning null in case no valid object could be built. For instance, Map::get returns null in case the key could not be found in the map.| andreabergia.com