Guava FluentIterable

Guava FluentIterable is part of the Guava collections library. It has great similarity to the Java 8 stream API.

This code filters a list with FluentIterable:

from(cities).filter(city -> city.contains(“e”)).transform(city -> “‘”+city + “‘”).limit(2).join(on(” “));

And this one produces the same result with Java 8 stream API:

cities.stream().filter(city -> city.contains(“e”)).map( city ->”‘”+city+”‘”).limit(2).collect(joining(” “));

Full code is available here.

FluentIterable should be considered as useful if you still work with JDK 7 , and you want functional programming.

This blog is also available in http://oren.kleks.com/?p=36

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com