Inspectopedia Help

Guava pseudo-functional call can be converted to Stream API call

Reports usages of Guava pseudo-functional code when Java Stream API is available.

Though Guava Iterable API provides functionality similar to Java Streams API, it's slightly different and may miss some features. Especially, primitive-specialized stream variants like IntStream are more performant than generic variants.

Example:

List<String> transformedIterable = Iterables.transform(someList, someTransformFunction);//warning: Pseudo functional style code

After the quick-fix is applied:

List<String> transformedIterable = someList.stream().map(someTransformFunction).collect(Collectors.toList());

Note: Code semantics can be changed; for example, Guava's Iterable.transform produces a lazy-evaluated iterable, but the replacement is eager-evaluated.

This inspection only reports if the language level of the project or module is 8 or higher.

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023