Inspectopedia Help

Simplifiable collector

Reports collectors that can be simplified.

In particular, some cascaded groupingBy() collectors can be expressed by using a simpler toMap() collector, which is also likely to be more performant.


Collectors.groupingByConcurrent(String::length, Collectors.collectingAndThen(Collectors.maxBy(String::compareTo), Optional::get));

After the quick-fix is applied:

Collectors.toConcurrentMap(String::length, Function.identity(), BinaryOperator.maxBy(String::compareTo));

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

New in 2017.1

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Java, 233.SNAPSHOT

Last modified: 13 July 2023