mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-01 02:38:59 +07:00
LambdaCanBeMethodCallInspection: support Java11 Pattern.asMatchPredicate()
IDEA-199626 Suggest Java 11 Pattern.asMatchPredicate() instead of x -> pattern.matcher(x).matches()
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// "Replace lambda expression with 'Pattern.asMatchPredicate()'" "true"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Main {
|
||||
private final Pattern pattern = Pattern.compile("[a-z]");
|
||||
|
||||
public <T extends CharSequence> void test() {
|
||||
Object str = "def";
|
||||
String xyz = Optional.of("xyz").map(x -> x).filter(x -> Objects.equals(x, str))
|
||||
.filter(pattern.asMatchPredicate()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Replace lambda expression with 'Pattern.asMatchPredicate()'" "true"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Main {
|
||||
private final Pattern pattern = Pattern.compile("[a-z]");
|
||||
|
||||
public <T extends CharSequence> void test() {
|
||||
Object str = "def";
|
||||
String xyz = Optional.of("xyz").map(x -> x).filter(x -> Objects.equals(x, str))
|
||||
.filter(str <caret>-> pattern.matcher(str).matches()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Replace lambda expression with 'Pattern.asMatchPredicate()'" "false"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Main {
|
||||
private final Pattern pattern = Pattern.compile("[a-z]");
|
||||
|
||||
public <T extends CharSequence> void test() {
|
||||
Object str = "def";
|
||||
String xyz = Optional.of("xyz").map(x -> x).filter(x -> Objects.equals(x, str))
|
||||
.filter(str <caret>-> pattern.matcher(str).matches()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user