Java
Simplifiable collector
Warning
New
Last modified: 03 December 2024Reports 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));
- 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
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, 243.23126 |
Thanks for your feedback!
Was this page helpful?