mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-04 12:17:12 +07:00
IDEA-CR-13704 ComparatorCombinatorsInspection: support block lambdas; EquivalenceChecker used
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparingInt" "true"
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort(Comparator.comparingInt(p -> p.getName().length()));
|
||||
}
|
||||
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparingLong" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Duration> durations) {
|
||||
durations.sort(Comparator.comparingLong(d -> d.getEnd() - d.getStart()));
|
||||
}
|
||||
|
||||
interface Duration {
|
||||
long getStart();
|
||||
long getEnd();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Replace with Comparator.comparingInt" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort((p1, p2) -> {<caret>
|
||||
return Integer.compare(p1.getName().length(), p2.getName().length());
|
||||
});
|
||||
}
|
||||
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparingLong" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Duration> durations) {
|
||||
durations.sort((d1, d2) -> Long.com<caret>pare(d1.getEnd()-d1.getStart(), d2.getEnd()-d2.getStart()));
|
||||
}
|
||||
|
||||
interface Duration {
|
||||
long getStart();
|
||||
long getEnd();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparingLong" "false"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Duration> durations) {
|
||||
durations.sort((d1, d2) -> Long.com<caret>pare(d1.getEnd()-d1.getStart(), d2.getEnd()-d1.getStart()));
|
||||
}
|
||||
|
||||
interface Duration {
|
||||
long getStart();
|
||||
long getEnd();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user