Kengo's blog

Technical articles about original projects, JVM, Static Analysis and TypeScript.

Combinators in Guava libraries

Do you want to use combinators in Java code? Guava libraries provide them for you.

Iterators.filter(unfiltered, predicate);
Iterators.transform(fromIterator, function);

Maps.filterKeys(unfiltered, keyPredicate);
Maps.filterValues(unfiltered, valuePredicate);
Maps.filterEntries(unfiltered, entryPredicate)
Maps.transformValues(fromMap, function);

Lists.transform(fromList, function);

Sets.filter(unfiltered, predicate);

See official document for detail.

But sadly, there is no reduce & fold in Guava.