Quick-fix for NPE in method reference to convert to lambda and add ?: (IDEA-176699)

This commit is contained in:
Tagir Valeev
2017-08-11 11:17:57 +07:00
parent a36ea9404c
commit 1e9f078fa4
7 changed files with 84 additions and 17 deletions
@@ -0,0 +1,13 @@
// "Replace with ' != null ?:'" "true"
import java.util.Arrays;
class A{
static String convert(String s) {
return s.isEmpty() ? s : null;
}
void test(String[] data){
Arrays.stream(data).map(A::convert).map(s -> s != null ? convert(s) : null).forEach(System.out::println);
}
}
@@ -0,0 +1,13 @@
// "Replace with ' != null ?:'" "true"
import java.util.Arrays;
class A{
static String convert(String s) {
return s.isEmpty() ? s : null;
}
void test(String[] data){
Arrays.stream(data).map(A::convert).map(s -> s != null ? s.trim() : null).forEach(System.out::println);
}
}
@@ -0,0 +1,13 @@
// "Replace with ' != null ?:'" "true"
import java.util.Arrays;
class A{
static String convert(String s) {
return s.isEmpty() ? s : null;
}
void test(String[] data){
Arrays.stream(data).map(A::convert).map(A::con<caret>vert).forEach(System.out::println);
}
}
@@ -0,0 +1,13 @@
// "Replace with ' != null ?:'" "true"
import java.util.Arrays;
class A{
static String convert(String s) {
return s.isEmpty() ? s : null;
}
void test(String[] data){
Arrays.stream(data).map(A::convert).map(String::tr<caret>im).forEach(System.out::println);
}
}