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.
Example:
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));
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
SimplifyCollector- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
This inspection depends on the Java feature 'Stream and Optional API', which is available since Java 8.
New in 2017.1
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 242.22892 |
Last modified: 11 September 2024