List<MyObject> (List<EventObject> events) { Predicate<EventObject> isPresent = event -> event.getMethod().isPresent(); // No warning -- IDEA-224757 Function<EventObject, MyObject> getItem = e -> e.getMethod().get(); return events.stream().filter(isPresent).map(getItem).collect(Collectors.toList()); }