mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-22 06:21:25 +07:00
UseCompareMethod: support boxed inputs and suggest "compareTo"
Allows to do IDEA-200365 in three steps now
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// "Fix all ''compare()' method can be used to compare primitives' problems in file" "true"
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Dto{
|
||||
Long id;
|
||||
|
||||
Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
List<Long> sortIds(List<Dto> list) {
|
||||
List<Long> ids = list.stream().map(Dto::getId).collect(Collectors.toList());
|
||||
ids.sort(new Comparator<Long>() {
|
||||
public int compare(Long o1, Long o2) {
|
||||
i<caret>f (o1 < o2) return -1;
|
||||
if (o1 > o2) return 1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
return ids;
|
||||
}
|
||||
|
||||
List<Dto> sortDtos(List<Dto> list) {
|
||||
list.sort(new Comparator<Dto>() {
|
||||
public int compare(Dto o1, Dto o2) {
|
||||
if (o1.getId() < o2.getId()) return -1;
|
||||
if (o1.getId() > o2.getId()) return 1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user