// "Replace Optional presence condition with functional style expression" "true-preview" import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.util.Optional; public class Main { public static Optional findAnnotation(Optional element) { return element.>map(annotatedElement -> annotatedElement.getAnnotations().length == 0 ? Optional.empty() : null).orElseGet(() -> findAnnotation((AnnotatedElement) null)); } private static Optional findAnnotation(AnnotatedElement element) { return Optional.empty(); } }