mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-22 06:21:25 +07:00
IDEA-161007 ComparatorCombinatorsInspection: better variable naming, support integer difference comparators
This commit is contained in:
@@ -4,7 +4,7 @@ import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort(Comparator.comparingDouble(p -> p.getName().length()));
|
||||
persons.sort(Comparator.comparingDouble(person -> person.getName().length()));
|
||||
}
|
||||
|
||||
interface Person {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.*;
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
String p;
|
||||
persons.sort(Comparator.comparing(p1 -> p1.name));
|
||||
persons.sort(Comparator.comparing(p2 -> p2.name));
|
||||
}
|
||||
|
||||
class Person {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with Comparator.comparingInt" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<String> data) {
|
||||
data.sort(Comparator.comparingInt(String::length));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort((p1, p2) -> Double.com<caret>pare(p1.getName().length(), p2.getName().length()));
|
||||
persons.sort((first, second) -> Double.com<caret>pare(first.getName().length(), second.getName().length()));
|
||||
}
|
||||
|
||||
interface Person {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with Comparator.comparingInt" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<String> data) {
|
||||
data.sort((d1, d2) -> d1.length() - d2.le<caret>ngth());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user