Inspectopedia
 
2024.3

'Comparator' combinator can be used

Warning
New
Last modified: 03 December 2024

Reports Comparator instances defined as lambda expressions that could be expressed using Comparator.comparing() calls. Chained comparisons which can be replaced by Comparator.thenComparing() expression are also reported.

Example:

After the quick-fixes are applied:

This inspection depends on the Java feature 'Lambda expressions', which is available since Java 8.