mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-163764 "Replace Optional.isPresent() checks with functional-style expressions" create uncompilable code
IDEA-163463 Stream API migration: type argument before map appears sometimes when it's unnecessary
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<Runnable> test(List<String> list) {
|
||||
List<Runnable> result = list.stream().<Runnable>map(s -> new Runnable() {
|
||||
List<Runnable> result = list.stream().map(s -> new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String str = s;
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<CharSequence> getListCharSequence(List<String> input) {
|
||||
List<CharSequence> result = input.stream().filter(s -> !s.isEmpty()).map(String::trim).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public List<String> getErrors(List<String> data) {
|
||||
List<String> def = Collections.singletonList("Not found");
|
||||
return data.stream().filter(s -> s.startsWith("xyz")).findFirst().<List<String>>map(s -> s.length() < 10 ? Collections.emptyList() : Arrays.asList()).orElse(def);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public Runnable getRunnable(List<String> data) {
|
||||
Runnable def = () -> {};
|
||||
return data.stream().filter(s -> s.startsWith("xyz")).findFirst().<Runnable>map(s -> s.length() > 2 ? s::trim : System.out::println).orElse(def);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public List<CharSequence> getListCharSequence(List<String> input) {
|
||||
List<CharSequence> result = new ArrayList<>();
|
||||
for(String s : in<caret>put) {
|
||||
if(!s.isEmpty()) {
|
||||
result.add(s.trim());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public List<String> getErrors(List<String> data) {
|
||||
List<String> def = Collections.singletonList("Not found");
|
||||
for(String s : dat<caret>a) {
|
||||
if(s.startsWith("xyz")) {
|
||||
return s.length() < 10 ? Collections.emptyList() : Arrays.asList();
|
||||
}
|
||||
}
|
||||
return def;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public Runnable getRunnable(List<String> data) {
|
||||
Runnable def = () -> {};
|
||||
for(String s : dat<caret>a) {
|
||||
if(s.startsWith("xyz")) {
|
||||
return s.length() > 2 ? s::trim : System.out::println;
|
||||
}
|
||||
}
|
||||
return def;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user