mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
Quick-fix to insert .filter(Objects::nonNull) (IDEA-176699)
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String accept(@NotNull String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).filter(Objects::nonNull).map(s -> accept(s)).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).filter(Objects::nonNull).map(s -> s.trim()).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String accept(@NotNull String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).filter(Objects::nonNull).map(this::accept).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).filter(Objects::nonNull).map(String::trim).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String accept(@NotNull String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String execute(Supplier<String> op) {
|
||||
return op.get();
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).filter(Objects::nonNull).map(s -> execute(() -> accept(s))).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String accept(@NotNull String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).map(s -> accept(s<caret>)).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "false"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String accept(@NotNull String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).map(s -> accept(s1<caret>)).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).map(s -> s.t<caret>rim()).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String accept(@NotNull String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).map(this:<caret>:accept).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).map(String:<caret>:trim).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class MyClass {
|
||||
@Nullable String convert(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String accept(@NotNull String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String execute(Supplier<String> op) {
|
||||
return op.get();
|
||||
}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
list.stream().map(this::convert).map(s -> execute(() -> accept(s<caret>))).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Insert 'filter(Objects::nonNull)' step" "false"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class MyClass {
|
||||
interface MyFunction {
|
||||
String apply(@Nullable String s);
|
||||
}
|
||||
|
||||
void doSmth(MyFunction fn) {}
|
||||
|
||||
void test(List<String> list, @Nullable String s1) {
|
||||
this.doSmth(s -> s.t<caret>rim());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user