Replace CompareToBuilder with Java 8's Comparator.comparing(...).thenComparing(...)
<p>Before Java 8, we implemented <code>Comparable.compareTo(...)</code> like this:</p>

<pre><code>public int compare(Person a, Person b) {
    return new CompareToBuilder()
            .append(a.getLastName(), b.getLastName())
            .append(a.getFirstName(), b.getFirstName())
            .toComparison();
}
</code></pre>

<p>As of Java 8, we can do it like this:</p>

<pre><code>public int compare(Person a, Person b) {
    return Comparator
            .comparing(Person::getLastName)
            .thenComparing(Person::getFirstName)
            .compare(a, b);
}
</code></pre>

<p>The new Java 8 way might allow us to drop the <code>commons-lang3</code> dependency. <strong>Is that new Java 8 way faster? Is there a way to automatically migrate?</strong> I didn't find an IntelliJ intention for it.</p>

<hr>

<p>Notice that it becomes a bit more complex when there are reverse orders and non natural comparison is involved:</p>

<pre><code>public int compare(SingleBenchmarkResult a, SingleBenchmarkResult b) {
    return new CompareToBuilder()
            .append(b.hasAnyFailure(), a.hasAnyFailure()) // Reverse
            .append(a.getAverageScore(), b.getAverageScore(), resilientScoreComparator)
            .toComparison();
}
</code></pre>

<p>becomes</p>

<pre><code>public int compare(SingleBenchmarkResult a, SingleBenchmarkResult b) {
    return Comparator
            .comparing(SingleBenchmarkResult::hasAnyFailure, Comparator.reverseOrder()) // Reverse
            .thenComparing(SingleBenchmarkResult::getAverageScore, resilientScoreComparator)
            .compare(a, b);
}
</code></pre>