mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 20:42:52 +07:00
IDEA-163764 "Replace Optional.isPresent() checks with functional-style expressions" create uncompilable code
IDEA-163463 Stream API migration: type argument before map appears sometimes when it's unnecessary
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Main<T> {
|
||||
public static <A extends Annotation> Optional<A> findAnnotation(Optional<? extends AnnotatedElement> element) {
|
||||
return element.<Optional<A>>map(annotatedElement -> annotatedElement.getAnnotations().length == 0 ? Optional.empty() : null).orElseGet(() -> findAnnotation((AnnotatedElement) null));
|
||||
}
|
||||
|
||||
private static <A extends Annotation> Optional<A> findAnnotation(AnnotatedElement element) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public static Runnable get(Optional<String> s) {
|
||||
return s.<Runnable>map(s1 -> s1::trim).orElse(null);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Main<T> {
|
||||
public static <A extends Annotation> Optional<A> findAnnotation(Optional<? extends AnnotatedElement> element) {
|
||||
if (element.isPre<caret>sent()) {
|
||||
return element.get().getAnnotations().length == 0 ? Optional.empty() : null;
|
||||
}
|
||||
return findAnnotation((AnnotatedElement)null);
|
||||
}
|
||||
|
||||
private static <A extends Annotation> Optional<A> findAnnotation(AnnotatedElement element) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "false"
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Main<T> {
|
||||
public static <A extends Annotation> Optional<A> findAnnotation(Optional<? extends AnnotatedElement> element) {
|
||||
if (element.isPre<caret>sent()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return findAnnotation((AnnotatedElement)null);
|
||||
}
|
||||
|
||||
private static <A extends Annotation> Optional<A> findAnnotation(AnnotatedElement element) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public static Runnable get(Optional<String> s) {
|
||||
if(s.isPres<caret>ent()) {
|
||||
return s.get()::trim;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user