mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-04 20:30:42 +07:00
IDEA-161007 Support method chains and comparingInt/Long/Double
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
// "Replace with Comparator.comparing" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort(Comparator.comparing(p -> p.getName().toLowerCase(Locale.ENGLISH)));
|
||||
}
|
||||
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Replace with Comparator.comparingDouble" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort(Comparator.comparingDouble(p -> p.getName().length()));
|
||||
}
|
||||
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparing" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
String p;
|
||||
persons.sort(Comparator.comparing(p1 -> p1.name));
|
||||
}
|
||||
|
||||
class Person {
|
||||
String name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparing" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort((p1, p2) -> p1.getName()<caret>.toLowerCase(Locale.ENGLISH)
|
||||
.compareTo(p2.getName().toLowerCase(Locale.ENGLISH)));
|
||||
}
|
||||
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparing" "false"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
persons.sort((p1, p2) -> p1.getName()<caret>.toLowerCase(Locale.ENGLISH)
|
||||
.compareTo(p2.getName().toLowerCase(Locale.CANADA)));
|
||||
}
|
||||
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Replace with Comparator.comparingDouble" "true"
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with Comparator.comparing" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void sort(List<Person> persons) {
|
||||
String p;
|
||||
persons.sort((p1, p2) -> p1.name.compar<caret>eTo(p2.name));
|
||||
}
|
||||
|
||||
class Person {
|
||||
String name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user