mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-27 00:41:51 +07:00
IDEA-160898 Inspection to convert several commonly-used lambdas to method references
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
Function<Object, String> fn = String.class::cast;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.function.Predicate;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
Predicate<Object> pred = String.class::isInstance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
Predicate<Object> pred = Objects::nonNull;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
Function<Object, String> fn = s -> (String)<caret>s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace lambda with method reference" "false"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
Function<Object, List<String>> fn = s -> (List<String>)<caret>s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace lambda with method reference" "false"
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
ToIntFunction<Object> fn = s -> (int)<caret>s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.function.Predicate;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
Predicate<Object> pred = s -> s instanceof <caret>String;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.function.Predicate;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
Predicate<Object> pred = s -> s != <caret>null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace lambda with method reference" "false"
|
||||
import java.util.function.Predicate;
|
||||
|
||||
class Bar extends Random {
|
||||
public void test(Object obj) {
|
||||
Predicate<Object> pred = s -> obj != <caret>null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user