mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 06:11:42 +07:00
IDEA-161007 Add new inspection to make comparator lambdas use Comparator.comparing() combinators (Currently only simple comparators supported)
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparing" "true"
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort(Comparator.comparing(Person::getName));
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with Comparator.comparing" "false"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort((p1, p2) -> p2.getNam<caret>e().compareTo(p1.getName()));
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with Comparator.comparing" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort((p1, p2) -> p1.getNam<caret>e().compareTo(p2.getName()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user