void (Optional<String> opt) { X x = MethodReferenceConstantValue::strangeMethod; Boolean aBoolean = opt.map(th<caret>is::strangeMethod) .map(Objects::nonNull) .map(Objects::isNull) .orElse(new Random().nextBoolean()); if (opt.isPresent()) { Stream.generate(opt::isPresent) .limit(10) .forEach(System.out::println); } }