mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-28 01:09:56 +07:00
IDEA-163062 [Java8][Feature] Function.identity() inspection
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// "Replace lambda expression with 'Predicate.isEqual()'" "true"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
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(Predicate.isEqual(str))
|
||||
.filter(str -> pattern.matcher(str).find()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "true"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
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(Function.identity()).filter(x -> Objects.equals(x, str))
|
||||
.filter(str -> pattern.matcher(str).find()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Replace lambda expression with 'Pattern.asPredicate()'" "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.asPredicate()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Replace lambda expression with 'Predicate.isEqual()'" "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 <caret>-> Objects.equals(x, str))
|
||||
.filter(str -> pattern.matcher(str).find()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "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 <caret>-> x).filter(x -> Objects.equals(x, str))
|
||||
.filter(str -> pattern.matcher(str).find()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "false"
|
||||
import java.io.Serializable;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Function<Object, Object> fn = (Function<Object, Object> & Serializable) x <caret>-> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "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 -> pattern.matcher(str).find()).orElse("");
|
||||
UnaryOperator<T> op = x <caret>-> x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Replace lambda expression with 'Pattern.asPredicate()'" "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).find()).orElse("");
|
||||
UnaryOperator<T> op = x -> x;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user